@seanyeh77/ui 0.43.1 → 0.44.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.
Files changed (129) hide show
  1. package/dist/bundle.js +14 -14
  2. package/dist/bundle.js.map +1 -1
  3. package/dist/components/Alert/Alert.d.ts +1 -1
  4. package/dist/components/Alert/Alert.js +2 -1
  5. package/dist/components/Alert/Alert.js.map +1 -1
  6. package/dist/components/DangerZone/DangerZone.d.ts +1 -1
  7. package/dist/components/DangerZone/DangerZone.js +2 -1
  8. package/dist/components/DangerZone/DangerZone.js.map +1 -1
  9. package/dist/components/DataTable/DataTable.d.ts +8 -3
  10. package/dist/components/DataTable/DataTable.js +155 -63
  11. package/dist/components/DataTable/DataTable.js.map +1 -1
  12. package/dist/components/DatePicker/DatePicker.d.ts +2 -2
  13. package/dist/components/DatePicker/DatePicker.js.map +1 -1
  14. package/dist/components/Dialog/Dialog.d.ts +1 -1
  15. package/dist/components/Dialog/Dialog.js +2 -1
  16. package/dist/components/Dialog/Dialog.js.map +1 -1
  17. package/dist/components/Drawer/Drawer.d.ts +1 -0
  18. package/dist/components/Drawer/Drawer.js +2 -1
  19. package/dist/components/Drawer/Drawer.js.map +1 -1
  20. package/dist/components/EmptyState/EmptyState.d.ts +2 -2
  21. package/dist/components/EmptyState/EmptyState.js +3 -2
  22. package/dist/components/EmptyState/EmptyState.js.map +1 -1
  23. package/dist/components/ErrorPage/ErrorPage.d.ts +1 -0
  24. package/dist/components/ErrorPage/ErrorPage.js +2 -1
  25. package/dist/components/ErrorPage/ErrorPage.js.map +1 -1
  26. package/dist/components/EventTimeline/EventTimeline.d.ts +1 -1
  27. package/dist/components/EventTimeline/EventTimeline.js +2 -1
  28. package/dist/components/EventTimeline/EventTimeline.js.map +1 -1
  29. package/dist/components/FileUpload/FileUpload.d.ts +1 -1
  30. package/dist/components/FileUpload/FileUpload.js +2 -1
  31. package/dist/components/FileUpload/FileUpload.js.map +1 -1
  32. package/dist/components/InlineCode/InlineCode.js +10 -6
  33. package/dist/components/InlineCode/InlineCode.js.map +1 -1
  34. package/dist/components/KpiCard/KpiCard.d.ts +2 -2
  35. package/dist/components/KpiCard/KpiCard.js +5 -4
  36. package/dist/components/KpiCard/KpiCard.js.map +1 -1
  37. package/dist/components/LayerGraph/LayerGraph.js +19 -9
  38. package/dist/components/LayerGraph/LayerGraph.js.map +1 -1
  39. package/dist/components/LoginCard/LoginCard.d.ts +1 -1
  40. package/dist/components/LoginCard/LoginCard.js.map +1 -1
  41. package/dist/components/Markdown/Markdown.js +19 -1
  42. package/dist/components/Markdown/Markdown.js.map +1 -1
  43. package/dist/components/MultiSelect/MultiSelect.d.ts +1 -1
  44. package/dist/components/MultiSelect/MultiSelect.js.map +1 -1
  45. package/dist/components/NotificationBell/NotificationBell.d.ts +1 -0
  46. package/dist/components/NotificationBell/NotificationBell.js +2 -1
  47. package/dist/components/NotificationBell/NotificationBell.js.map +1 -1
  48. package/dist/components/Select/Select.d.ts +1 -1
  49. package/dist/components/Select/Select.js.map +1 -1
  50. package/dist/components/SettingsLayout/SettingsLayout.d.ts +1 -1
  51. package/dist/components/SettingsLayout/SettingsLayout.js +2 -1
  52. package/dist/components/SettingsLayout/SettingsLayout.js.map +1 -1
  53. package/dist/components/Tabs/Tabs.d.ts +4 -1
  54. package/dist/components/Tabs/Tabs.js +5 -2
  55. package/dist/components/Tabs/Tabs.js.map +1 -1
  56. package/dist/components/TextArea/TextArea.d.ts +2 -1
  57. package/dist/components/TextArea/TextArea.js +3 -2
  58. package/dist/components/TextArea/TextArea.js.map +1 -1
  59. package/dist/components/TextField/TextField.d.ts +2 -2
  60. package/dist/components/TextField/TextField.js.map +1 -1
  61. package/dist/components/Toast/Toast.d.ts +1 -1
  62. package/dist/components/Toast/Toast.js +2 -1
  63. package/dist/components/Toast/Toast.js.map +1 -1
  64. package/dist/css/Alert.css +1 -0
  65. package/dist/css/Button.css +1 -0
  66. package/dist/css/Checkbox.css +1 -0
  67. package/dist/css/CodeView.css +1 -1
  68. package/dist/css/DangerZone.css +1 -0
  69. package/dist/css/DataTable.css +177 -38
  70. package/dist/css/DatePicker.css +1 -0
  71. package/dist/css/DateRangePicker.css +1 -0
  72. package/dist/css/Drawer.css +1 -0
  73. package/dist/css/EmptyState.css +1 -0
  74. package/dist/css/ErrorPage.css +1 -0
  75. package/dist/css/EventTimeline.css +1 -0
  76. package/dist/css/FileUpload.css +1 -0
  77. package/dist/css/KpiCard.css +1 -0
  78. package/dist/css/LoginCard.css +1 -0
  79. package/dist/css/Markdown.css +29 -1
  80. package/dist/css/MultiSelect.css +1 -0
  81. package/dist/css/NotificationBell.css +1 -0
  82. package/dist/css/ProjectSwitcher.css +6 -1
  83. package/dist/css/Select.css +1 -0
  84. package/dist/css/SettingsLayout.css +1 -0
  85. package/dist/css/Suggestion.css +1 -1
  86. package/dist/css/Tabs.css +6 -6
  87. package/dist/css/Term.css +1 -1
  88. package/dist/css/TextArea.css +1 -0
  89. package/dist/css/TextField.css +1 -0
  90. package/dist/css/Toast.css +1 -0
  91. package/dist/css/Tour.css +1 -1
  92. package/dist/css/TreeList.css +1 -0
  93. package/dist/css/Workbench.css +12 -0
  94. package/dist/format.js +3 -1
  95. package/dist/format.js.map +1 -1
  96. package/dist/index.js +2 -2
  97. package/dist/internal/Field.js +3 -2
  98. package/dist/internal/Field.js.map +1 -1
  99. package/dist/internal/codeSpans.js +20 -0
  100. package/dist/internal/codeSpans.js.map +1 -0
  101. package/dist/styles.css +316 -133
  102. package/docs/Alert.md +1 -0
  103. package/docs/Card.md +3 -3
  104. package/docs/DangerZone.md +1 -0
  105. package/docs/DataTable.md +29 -19
  106. package/docs/DatePicker.md +1 -0
  107. package/docs/Dialog.md +1 -0
  108. package/docs/Drawer.md +1 -0
  109. package/docs/EmptyState.md +1 -0
  110. package/docs/ErrorPage.md +1 -0
  111. package/docs/EventTimeline.md +1 -0
  112. package/docs/FileUpload.md +1 -0
  113. package/docs/Format.md +1 -1
  114. package/docs/KpiCard.md +1 -0
  115. package/docs/LoginCard.md +1 -0
  116. package/docs/Markdown.md +3 -0
  117. package/docs/MultiSelect.md +1 -0
  118. package/docs/NotificationBell.md +1 -0
  119. package/docs/Select.md +1 -0
  120. package/docs/SettingsLayout.md +1 -0
  121. package/docs/Tabs.md +2 -2
  122. package/docs/Term.md +1 -0
  123. package/docs/TextArea.md +1 -0
  124. package/docs/TextField.md +1 -0
  125. package/docs/Toast.md +1 -0
  126. package/docs/data.md +4 -3
  127. package/docs/guidelines.md +4 -4
  128. package/docs/layout.md +1 -1
  129. package/package.json +2 -2
package/dist/bundle.js CHANGED
@@ -76,20 +76,20 @@ var t=f();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=ty
76
76
  * This source code is licensed under the MIT license found in the
77
77
  * LICENSE file in the root directory of this source tree.
78
78
  */
79
- var t=f(),n=gu();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),vu=/* @__PURE__ */ s(((e,t)=>{t.exports=_u()})),yu=gu(),bu=vu();let xu=Oc(19)?wu:Tu;function Su(e,t,n,r,i){return xu(e,t,n,r,i)}function Cu(e,t,n,r,i){let a=y.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,yu.useSyncExternalStore)(e.subscribe,a,a)}Ei({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,i)||(t=!0,r.value=i)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=/* @__PURE__ */ new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,yu.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function wu(e,t,n,r,i){let a=Ti();if(!a)return Cu(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],s.store===e&&s.selector===t&&Object.is(s.a1,n)&&Object.is(s.a2,r)&&Object.is(s.a3,i)||(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.value=t(e.getSnapshot(),n,r,i))):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i)},a.syncHooks.push(s)),s.value}function Tu(e,t,n,r,i){return(0,bu.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var Eu=class{static create(e){return new this(e)}constructor(e){this.state=e,this.listeners=/* @__PURE__ */ new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return Su(this,e,t,n,r)}},Du=class extends Eu{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){y.useDebugValue(e);let n=this;X(()=>{n.state[e]!==t&&n.set(e,t)},[n,e,t])}useSyncedValueWithCleanup(e,t){let n=this;X(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this,n=Object.values(e);X(()=>{t.update(e)},[t,...n])}useControlledProp(e,t){y.useDebugValue(e);let n=this,r=t!==void 0;X(()=>{r&&!Object.is(n.state[e],t)&&n.setState({...n.state,[e]:t})},[n,e,t,r])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return y.useDebugValue(e),Su(this,this.selectors[e],t,n,r)}useContextCallback(e,t){y.useDebugValue(e);let n=$(t??Ai);this.context[e]=n}useStateSetter(e){let t=y.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}};let Ou={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId};var ku=class extends Du{constructor(e){let{syncOnly:t,nested:n,onOpenChange:r,triggerElements:i,...a}=e;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:dl(),nested:n,triggerElements:i},Ou),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&oa(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);let n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit(`openchange`,n)};setOpen=(e,t)=>{this.syncOnly||this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function Au(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new ku({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,openedWithoutTrigger:!1,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:Mi,inactiveTriggerProps:Mi,popupProps:Mi}}let ju=e=>e.triggerIdProp??e.activeTriggerId,Mu=e=>e.openProp??e.open,Nu=e=>(e.popupElement?.id??e.floatingId)||void 0;function Pu(e,t){return t!==void 0&&Mu(e)&&ju(e)===t}function Fu(e,t){return Pu(e,t)?!0:t!==void 0&&Mu(e)&&ju(e)==null&&!e.openedWithoutTrigger&&e.triggerCount===1}let Iu={open:Mu,mounted:e=>e.mounted,transitionStatus:e=>Mu(e)&&!e.mounted?`starting`:e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:ju,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:Nu,isTriggerActive:(e,t)=>t!==void 0&&ju(e)===t,isOpenedByTrigger:(e,t)=>Pu(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&ju(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>Fu(e,t)?Nu(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function Lu(e){let t=y.useCallback(t=>e===void 0?Ai:e.subscribeStore(t),[e]),n=y.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,yu.useSyncExternalStore)(t,n,()=>e?.serverStore)}function Ru(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=Dc(),a=hl()!=null,o=Si(()=>new ku({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new mu,floatingId:i,syncOnly:!1,nested:a})).current;return X(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=fa(r.reference)?r.reference:null),r.floating!==void 0&&(e.floatingElement=r.floating),o.update(e)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}let zu=Yi&&Zi;function Bu(e,t={}){let{enabled:n=!0,delay:r}=t,{events:i,dataRef:a}=e.context,o=y.useRef(!1),s=y.useRef(null),c=y.useRef(!0),l=zi();y.useEffect(()=>{let t=e.select(`domReferenceElement`);if(!n)return;let r=la(t);function i(){let t=e.select(`domReferenceElement`);!e.select(`open`)&&pa(t)&&t===Ma(Zo(t))&&(o.current=!0,s.current=t)}function a(){c.current=!0}function l(){c.current=!1}return Po(No(r,`blur`,i),zu&&No(r,`keydown`,a,!0),zu&&No(r,`pointerdown`,l,!0))},[e,n]),y.useEffect(()=>{if(!n)return;function t(t){if(t.reason===`trigger-press`||t.reason===`escape-key`){let t=e.select(`domReferenceElement`);fa(t)&&(s.current=t,o.current=!0)}}return i.on(`openchange`,t),()=>{i.off(`openchange`,t)}},[i,n,e]);let u=y.useMemo(()=>{function t(){o.current=!1,s.current=null}return{onMouseLeave(){t()},onFocus(n){let i=n.currentTarget;if(o.current){if(s.current===i)return;t()}let a=Pa(n.nativeEvent);if(fa(a)){if(zu&&!n.relatedTarget){if(!c.current&&!to(a))return}else if(!io(a))return}let u=Qa(n.relatedTarget,e.context.triggerElements),{nativeEvent:d,currentTarget:f}=n;e.select(`open`)&&u||!r?e.setOpen(!0,Q(go,d,f)):l.start(r,()=>{o.current||e.setOpen(!0,Q(go,d,f))})},onBlur(n){t();let r=n.relatedTarget,i=n.nativeEvent,o=fa(r)&&r.hasAttribute(lc(`focus-guard`))&&r.getAttribute(`data-type`)===`outside`;l.start(0,()=>{let t=e.select(`domReferenceElement`),n=Ma(Zo(t));!r&&n===t||Z(a.current.floatingContext?.refs.floating.current,n)||Z(t,n)||o||Qa(r??n,e.context.triggerElements)||e.setOpen(!1,Q(go,i))})}}},[a,r,e,l]);return y.useMemo(()=>n?{reference:u,trigger:u}:{},[n,u])}var Vu=class e{pointerType=void 0;interactedInside=!1;handler=void 0;blockMouseMove=!0;performedPointerEventsMutation=!1;pointerEventsScopeElement=null;pointerEventsReferenceElement=null;pointerEventsFloatingElement=null;restTimeoutPending=!1;openChangeTimeout=new Ri;restTimeout=new Ri;handleCloseOptions=void 0;static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose};let Hu=/* @__PURE__ */ new WeakMap;function Uu(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&Hu.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),Hu.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function Wu(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=Hu.get(n);a&&a!==e&&Uu(a),Uu(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,Hu.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function Gu(e){let t=e.context.dataRef.current,n=Si(()=>t.hoverInteractionState??Vu.create()).current;return t.hoverInteractionState||=n,Li(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function Ku(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=e.useState(`open`),o=e.useState(`floatingElement`),s=e.useState(`domReferenceElement`),{dataRef:c}=e.context,l=gl(),u=hl(),d=Gu(e),f=zi(),p=$(()=>lo(c.current.openEvent?.type,d.interactedInside)),m=$(()=>uo(c.current.openEvent?.type)),h=$(()=>{Uu(d)});X(()=>{a||(d.pointerType=void 0,d.restTimeoutPending=!1,d.interactedInside=!1,h())},[a,d,h]),y.useEffect(()=>h,[h]),X(()=>{if(n&&a&&d.handleCloseOptions?.blockPointerEvents&&m()&&fa(s)&&o){let e=s,t=o,n=Zo(o),r=l?.nodesRef.current.find(e=>e.id===u)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=d.pointerEventsScopeElement===t?null:d.pointerEventsScopeElement,a=r===t?null:r,c=d.handleCloseOptions?.getScope?.()??i??a??Na(e,`[data-rootownerid]`)??n.body;return Wu(d,{scopeElement:c,referenceElement:e,floatingElement:t}),()=>{h()}}},[n,a,s,o,d,m,l,u,h]),y.useEffect(()=>{if(!n)return;function t(){return!!(l&&u&&sc(l.nodesRef.current,u).length>0)}function a(t){let n=so(r,`close`,d.pointerType),i=()=>{e.setOpen(!1,Q(ho,t)),l?.events.emit(`floating.closed`,t)};n?d.openChangeTimeout.start(n,i):(d.openChangeTimeout.clear(),i())}function s(e){let t=Pa(e);no(t)?d.interactedInside=Na(t,`[aria-haspopup]`)!=null:d.interactedInside=!1}function g(){d.openChangeTimeout.clear(),f.clear(),l?.events.off(`floating.closed`,v),h()}function _(n){if(t()&&l){l.events.on(`floating.closed`,v);return}if(Qa(n.relatedTarget,e.context.triggerElements))return;let r=c.current.floatingContext?.nodeId??i,o=n.relatedTarget;l&&r&&fa(o)&&sc(l.nodesRef.current,r,!1).some(e=>Z(e.context?.elements.floating,o))||(d.handler?d.handler(n):(h(),m()&&!p()&&a(n)))}function v(n){l&&u&&!t()&&f.start(0,()=>{l.events.off(`floating.closed`,v),e.setOpen(!1,Q(ho,n)),l.events.emit(`floating.closed`,n)})}let y=o;return Po(y&&No(y,`mouseenter`,g),y&&No(y,`mouseleave`,_),y&&No(y,`pointerdown`,s,!0),()=>{l?.events.off(`floating.closed`,v)})},[n,o,e,c,r,i,m,p,h,d,l,u,f])}let qu={current:null};function Ju(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=qu,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:f,shouldOpen:p,guardStaleOpen:m=!1}=t,{dataRef:h,events:g}=e.context,_=gl(l),v=Gu(e),x=y.useRef(!1),S=Vo(i),C=Vo(r),w=Vo(o),T=Vo(n),E=Vo(p),D=Vo(f),O=$(()=>lo(h.current.openEvent?.type,v.interactedInside)),k=$(()=>E.current?.()!==!1),A=$((t,n,r)=>{let i=e.context.triggerElements;if(i.hasElement(n))return!t||!Z(t,n);if(!fa(r))return!1;let a=r;return i.hasMatchingElement(e=>Z(e,a))&&(!t||!Z(t,a))}),j=$(()=>{v.handler&&=(Zo(e.select(`domReferenceElement`)).removeEventListener(`mousemove`,v.handler),void 0)}),M=$(()=>{Uu(v)});return u&&(v.handleCloseOptions=i?.__options),y.useEffect(()=>j,[j]),y.useEffect(()=>{if(!n)return;function e(e){e.open?x.current=!1:(x.current=e.reason===ho,j(),v.openChangeTimeout.clear(),v.restTimeout.clear(),v.blockMouseMove=!0,v.restTimeoutPending=!1)}return g.on(`openchange`,e),()=>{g.off(`openchange`,e)}},[n,g,v,j]),y.useEffect(()=>{if(!n)return;function t(t,n=!0){let r=so(C.current,`close`,v.pointerType);r?v.openChangeTimeout.start(r,()=>{e.setOpen(!1,Q(ho,t)),_?.events.emit(`floating.closed`,t)}):n&&(v.openChangeTimeout.clear(),e.setOpen(!1,Q(ho,t)),_?.events.emit(`floating.closed`,t))}let r=c.current??(u?e.select(`domReferenceElement`):null);if(!fa(r))return;function i(t){if(v.openChangeTimeout.clear(),v.blockMouseMove=!1,a&&!aa(v.pointerType))return;let n=co(w.current),r=so(C.current,`open`,v.pointerType),i=Pa(t),o=t.currentTarget??null,s=e.select(`domReferenceElement`),c=o;if(fa(i)&&!e.context.triggerElements.hasElement(i)){for(let t of e.context.triggerElements.elements())if(Z(t,i)){c=t;break}}fa(o)&&fa(s)&&!e.context.triggerElements.hasElement(o)&&Z(o,s)&&(c=s);let l=c!=null&&A(s,c,i),u=e.select(`open`),d=D.current?.()??e.select(`transitionStatus`)===`ending`,f=!u&&d&&x.current,p=!l&&fa(c)&&fa(s)&&Z(s,c)&&f,m=n>0&&!r,h=l&&(u||f)||p,g=!u||l;h?k()&&e.setOpen(!0,Q(ho,t,c)):m||(r?v.openChangeTimeout.start(r,()=>{g&&k()&&e.setOpen(!0,Q(ho,t,c))}):g&&k()&&e.setOpen(!0,Q(ho,t,c)))}function o(n){if(O()){M();return}j();let r=Zo(e.select(`domReferenceElement`));v.restTimeout.clear(),v.restTimeoutPending=!1;let i=h.current.floatingContext??d?.();if(!Qa(n.relatedTarget,e.context.triggerElements)){if(S.current&&i){e.select(`open`)||v.openChangeTimeout.clear();let a=c.current;v.handler=S.current({...i,tree:_,x:n.clientX,y:n.clientY,onClose(){M(),j(),T.current&&!O()&&a===e.select(`domReferenceElement`)&&t(n,!0)}}),r.addEventListener(`mousemove`,v.handler),v.handler(n)}else v.pointerType===`touch`&&Z(e.select(`floatingElement`),n.relatedTarget)||t(n)}}function l(e){Z(r,e.relatedTarget)||(v.openChangeTimeout.clear(),v.restTimeout.clear(),v.restTimeoutPending=!1)}let f=m?No(r,`mouseout`,l):void 0;return s?Po(No(r,`mousemove`,i,{once:!0}),No(r,`mouseenter`,i),No(r,`mouseleave`,o),f):Po(No(r,`mouseenter`,i),No(r,`mouseleave`,o),f)},[j,M,h,C,e,n,S,v,u,A,O,a,s,w,c,_,T,d,D,k,m]),y.useMemo(()=>{if(!n)return;function t(e){v.pointerType=e.pointerType}return{onPointerDown:t,onPointerEnter:t,onMouseMove(t){let{nativeEvent:n}=t,r=t.currentTarget,i=e.select(`domReferenceElement`),o=e.select(`open`),s=A(i,r,t.target);if(a&&!aa(v.pointerType))return;if(o&&s&&v.handleCloseOptions?.blockPointerEvents){let t=e.select(`floatingElement`);if(t){let e=v.handleCloseOptions?.getScope?.()??r.ownerDocument.body;Wu(v,{scopeElement:e,referenceElement:r,floatingElement:t})}}let c=co(w.current);if(o&&!s||c===0||!s&&v.restTimeoutPending&&t.movementX**2+t.movementY**2<2)return;v.restTimeout.clear();function l(){if(v.restTimeoutPending=!1,O())return;let t=e.select(`open`);!v.blockMouseMove&&(!t||s)&&k()&&e.setOpen(!0,Q(ho,n,r))}v.pointerType===`touch`?b.flushSync(()=>{l()}):s&&o?l():(v.restTimeoutPending=!0,v.restTimeout.start(c,l))}}},[n,v,O,A,a,e,w,k])}function Yu(e){return Zi&&e.movementX===0&&e.movementY===0}function Xu(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function Zu(e,t){return Xu(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function Qu(e,t,n){return Xu(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function $u(e,t,n){return Xu(t,n?e===Fa:e===Ia,e===`ArrowDown`)}function ed(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===`Escape`:Xu(t,n?e===Ia:e===Fa,e===`ArrowUp`)}function td(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:l=!1,rtl:u=!1,virtual:d=!1,focusItemOnOpen:f=`auto`,focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:h=void 0,orientation:g=`vertical`,triggerOrientation:_=g,parentOrientation:v,id:b,resetOnPointerLeave:x=!0,externalTree:S,nestedReturnFocusRef:C,grid:w}=t,T=w!=null,E=e.useState(`open`),D=e.useState(`floatingElement`),O=e.useState(`domReferenceElement`),k=e.context.dataRef,A=ao(D),j=ro(O),M=Vo(A),N=hl(),P=gl(S),F=y.useRef(f),I=y.useRef(o??-1),L=y.useRef(null),R=y.useRef(!0),z=$(e=>{i(I.current===-1?null:I.current,e)}),B=y.useRef(!!D),V=y.useRef(E),H=y.useRef(!1),U=y.useRef(!1),ee=y.useRef(null),te=Vo(h),ne=Vo(E),W=Vo(o),re=Vo(x),ie=Xo(),G=Xo(),K=$(()=>{ie.cancel();function e(e){d||(ee.current=dc(e,{sync:H.current,preventScroll:!0}))}let t=n.current[I.current],r=U.current;t&&e(t),(H.current?e=>e():e=>ie.request(e))(()=>{let i=n.current[I.current]||t;i&&(t||e(i),le&&(r||!R.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});X(()=>{k.current.orientation=g},[k,g]),X(()=>{E||(L.current=null),E&&f===`auto`||(F.current=f)},[E,f]),X(()=>{a&&(E&&D?(I.current=o??-1,F.current&&o!=null&&(U.current=!0,z())):B.current&&(I.current=-1,z()))},[a,E,D,o,z]),X(()=>{if(a){if(!E)H.current=!1;else if(D){if(r==null){if(H.current=!1,W.current!=null)return;if(B.current&&(I.current=-1,K()),(!V.current||!B.current)&&F.current&&(L.current!=null||F.current===!0&&L.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>G.request(e):queueMicrotask)(t),e+=1):(I.current=L.current==null||Qu(L.current,_,u)||l?js(n):Ms(n),L.current=null,z())};t()}}else As(n.current,r)||(I.current=r,K(),U.current=!1)}}},[a,E,D,r,W,l,n,_,u,z,K,G]),X(()=>{if(!a||D||!P||d||!B.current)return;let e=P.nodesRef.current,t=e.find(e=>e.id===N)?.context?.elements.floating,n=Ma(Zo(O??t??null)),r=e.some(e=>e.context&&Z(e.context.elements.floating,n));t&&!r&&R.current&&t.focus({preventScroll:!0})},[a,D,O,P,N,d]),X(()=>{V.current=E,B.current=!!D});let q=r!=null,ae=$(e=>{if(!ne.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(I.current!==t||r!==t)&&(I.current=t,z(e))}),oe=$(()=>v??P?.nodesRef.current.find(e=>e.id===N)?.context?.dataRef?.current.orientation),se=$(()=>js(n,te.current)),ce=$(t=>{if(R.current=!1,H.current=!0,t.which===229||!ne.current&&t.currentTarget===M.current)return;if(l&&ed(t.key,g,u,T)){Zu(t.key,oe())||ta(t),e.setOpen(!1,Q(wo,t.nativeEvent));let n=C?.current??O;pa(n)&&n.focus();return}r!=null&&r!==I.current&&!As(n.current,r)&&(I.current=r);let i=I.current,a=js(n,h),o=Ms(n,h);if(j||(t.key===`Home`&&(ta(t),I.current=a,z(t)),t.key===`End`&&(ta(t),I.current=o,z(t))),w!=null){let e=w(t,I.current,n,g,c,u,h,a,o);if(e!=null&&e!==I.current&&(I.current=e,z(t)),g===`both`)return}if(Zu(t.key,g)){ta(t);let e=Ma(t.currentTarget.ownerDocument);if(E&&!d&&Z(t.currentTarget,e)&&!n.current.some(t=>t!=null&&Z(t,e))){I.current=Qu(t.key,g,u)?a:o,z(t),r===I.current&&K();return}let{index:l,wrapped:f}=Ns(n.current,i,{decrement:!Qu(t.key,g,u),loopFocus:c,allowEscape:s,disabledIndices:h,minIndex:a,maxIndex:o});f&&(H.current=!1),I.current=l,z(t)}}),le=y.useMemo(()=>({onFocus(e){H.current=!0,ae(e)},onClick({currentTarget:e}){d||e.focus({preventScroll:!0})},onMouseMove(e){Yu(e)||(H.current=!0,U.current=!1,p&&ae(e))},onPointerLeave(e){if(!ne.current||!R.current||e.pointerType===`touch`)return;H.current=!0;let t=e.relatedTarget;if(p&&!n.current.includes(t)&&re.current&&(ee.current?.(),ee.current=null,I.current=-1,z(e),!d)){let e=M.current,t=Ma(Zo(e));e&&Z(e,t)&&e.focus({preventScroll:!0})}}}),[ae,ne,M,p,n,z,re,d]),J=y.useMemo(()=>d&&E&&q&&{"aria-activedescendant":`${b}-${r}`},[d,E,q,b,r]),ue=y.useMemo(()=>({...j?{}:J,onKeyDown(t){if(t.key===`Tab`&&t.shiftKey&&E&&!d){let n=Pa(t.nativeEvent);if(n&&!Z(M.current,n))return;ta(t);let r=Q(So,t.nativeEvent);e.setOpen(!1,r);let i=C?.current??O;!r.isCanceled&&pa(i)&&i.focus()}else ce(t)},onPointerMove(e){Yu(e)||(R.current=!0)}}),[J,ce,M,j,e,E,d,O,C]),de=y.useMemo(()=>{function t(t){e.setOpen(!0,Q(wo,t.nativeEvent,t.currentTarget))}function n(e){f===`auto`&&ra(e.nativeEvent)&&(F.current=!d)}function r(e){F.current=f,f===`auto`&&ia(e.nativeEvent)&&(F.current=!0)}return{onKeyDown(n){let r=e.select(`open`);R.current=!1;let i=n.key.startsWith(`Arrow`),a=$u(n.key,oe(),u),o=Zu(n.key,r?g:_),s=(l?a:o)||n.key===`Enter`||n.key.trim()===``;if(d&&r&&(!l||to(n.currentTarget)))return ce(n);if(r||m||!i){if(s){let e=Zu(n.key,oe());L.current=l&&e?null:n.key}l?a&&(ta(n),r?(I.current=se(),z(n),d&&M.current?.focus()):t(n)):o&&(W.current!=null&&(I.current=W.current),ta(n),!r&&m?t(n):ce(n),r&&z(n))}},onFocus(t){t.target===t.currentTarget&&e.select(`open`)&&!d&&(I.current=-1,z(t))},onPointerDown:r,onPointerEnter:r,onMouseDown:n,onClick:n}},[ce,f,se,l,z,e,m,g,_,oe,u,W,d,M]),fe=y.useMemo(()=>({...J,...de}),[J,de]);return y.useMemo(()=>a?{reference:fe,floating:ue,item:le,trigger:de}:{},[a,fe,ue,de,le])}function nd(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=$(s),f=e.useState(`open`),p=zi(),m=y.useRef(``),h=y.useRef(u??i??-1),g=y.useRef(null),_=$(e=>{function t(e){return r?.current[e]}function s(e){let n=t(e);return n&&!Rs(n)||n?.matches(`:disabled`)?!1:o==null||!Is(ji,e,o)}function c(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(e[n]?.toLowerCase().startsWith(i)&&s(n))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(ta(e),d?.(!0)),m.current.length>0&&m.current[0]!==` `&&c(_,m.current)===-1&&e.key!==` `&&d?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(ta(e),d?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&s(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,d?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=c(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,d?.(!1)):(a?.(b,e),g.current=b)}),v=$(t=>{let n=t.relatedTarget,r=e.select(`domReferenceElement`),i=e.select(`floatingElement`);Z(r,n)||Z(i,n)||(p.clear(),m.current=``,h.current=g.current,d?.(!1))});X(()=>{(f||u===null)&&(p.clear(),g.current=null,m.current!==``&&(m.current=``,d?.(!1)))},[f,u,p,d]);let b=y.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return y.useMemo(()=>c?{reference:b,floating:b}:{},[c,b])}let rd=.5;function id(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function ad(e,t,n,r,i,a,o,s,c,l){let u=!1;return id(e,t,n,r,i,a)&&(u=!u),id(e,t,i,a,o,s)&&(u=!u),id(e,t,o,s,c,l)&&(u=!u),id(e,t,c,l,n,r)&&(u=!u),u}function od(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function sd(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function cd(e={}){let{blockPointerEvents:t=!1}=e,n=new Ri,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*.010000000000000002;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=Pa(r),g=r.type===`mouseleave`,_=Z(u,h),v=Z(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&fa(r.relatedTarget)&&Z(u,r.relatedTarget))return;function y(){return!!(s&&sc(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=sd(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=sd(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=sd(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=sd(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!od(d,f,x)||!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?rd/2:rd*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+rd+1,o=C||T?S.bottom-rd:S.top,s=C?T?S.bottom-rd:S.top:S.bottom-rd;M=ad(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?rd/2:rd*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-rd,o=C||T?S.top+rd:S.bottom,s=C?T?S.top+rd:S.bottom:S.top+rd;M=ad(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?rd/2:rd*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+rd+1,o=w||E?S.right-rd:S.left,s=w?E?S.right-rd:S.left:S.right-rd;M=ad(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?rd/2:rd*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-rd,o=w||E?S.left+rd:S.right,s=w?E?S.left+rd:S.right:S.left+rd;M=ad(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}function ld(e,t,n){let{reference:r,floating:i}=e,a=ms(t),o=hs(t),s=ps(o),c=us(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=ds(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function ud(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=ls(t,e),p=Ds(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Os(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Os(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}let dd=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:ud},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=ld(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<50&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=ld(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},fd=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=ls(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=us(r),_=ms(o),v=us(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Ts(o)]:_s(o)),x=p!==`none`;!d&&x&&b.push(...ws(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=gs(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===ms(t)||T.every(e=>ms(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=ms(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},pd=/*#__PURE__*/ new Set([`left`,`top`]);async function md(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=us(n),s=ds(n),c=ms(n)===`y`,l=pd.has(o)?-1:1,u=a&&c?-1:1,d=ls(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}let hd=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await md(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},gd=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=ls(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=ms(i),p=fs(f),m=u[p],h=u[f],g=(e,t)=>cs(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},_d=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=ls(e,t),u={x:n,y:r},d=ms(i),f=fs(d),p=u[f],m=u[d],h=ls(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=pd.has(us(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},vd=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=ls(e,t),c=await i.detectOverflow(t,s),l=us(n),u=ds(n),d=ms(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=ns(p-c[m],g),y=ns(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*rs(c.left,c.right):S=p-2*rs(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function yd(e){let t=Ea(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=pa(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=is(n)!==a||is(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function bd(e){return fa(e)?e:e.contextElement}function xd(e){let t=bd(e);if(!pa(t))return os(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=yd(t),o=(a?is(n.width):n.width)/r,s=(a?is(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}let Sd=/*#__PURE__*/ os(0);function Cd(e){let t=la(e);return!wa()||!t.visualViewport?Sd:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function wd(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===la(e)}function Td(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=bd(e),o=os(1);t&&(r?fa(r)&&(o=xd(r)):o=xd(e));let s=wd(a,n,r)?Cd(a):os(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=la(a),t=fa(r)?la(r):r,n=e,i=ja(n);for(;i&&t!==n;){let e=xd(i),t=i.getBoundingClientRect(),r=Ea(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=la(i),i=ja(n)}}return Os({width:u,height:d,x:c,y:l})}function Ed(e,t){let n=Da(e).scrollLeft;return t?t.left+n:Td(ua(e)).left+n}function Dd(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Ed(e,n),y:n.top+t.scrollTop}}function Od(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=ua(r),s=t?_a(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=os(1),u=os(0),d=pa(r);if((d||!a)&&((ca(r)!==`body`||ha(o))&&(c=Da(r)),d)){let e=Td(r);l=xd(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Dd(o,c):os(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function kd(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Ad(e){let t=Da(e),n=e.ownerDocument.body,r=rs(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=rs(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Ed(e),o=-t.scrollTop;return Ea(n).direction===`rtl`&&(a+=rs(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}function jd(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=la(e),a=ua(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!wa()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Ed(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=25&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Md(e,t){let n=Td(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=xd(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Nd(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=jd(e,n,t);else if(t===`document`)r=Ad(ua(e));else if(fa(t))r=Md(t,n);else{let n=Cd(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Os(r)}function Pd(e,t){let n=t.get(e);if(n)return n;let r=Aa(e,[],!1).filter(e=>fa(e)&&ca(e)!==`body`),i=null,a=Ea(e).position===`fixed`,o=a?Oa(e):e;for(;fa(o)&&!Ta(o);){let e=Ea(o),t=Sa(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Oa(o)}return t.set(e,r),r}function Fd(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?_a(t)?[]:Pd(t,this._c):[].concat(n),r],o=Nd(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Nd(t,a[e],i);s=rs(n.top,s),c=ns(n.right,c),l=ns(n.bottom,l),u=rs(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Id(e){let{width:t,height:n}=yd(e);return{width:t,height:n}}function Ld(e,t,n){let r=pa(t),i=ua(t),a=n===`fixed`,o=Td(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=os(0);if((r||!a)&&((ca(t)!==`body`||ha(i))&&(s=Da(t)),r)){let e=Td(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=Ed(i));let l=i&&!r&&!a?Dd(i,s):os(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Rd(e){return Ea(e).position===`static`}function zd(e,t){if(!pa(e)||Ea(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return ua(e)===n&&(n=n.ownerDocument.body),n}function Bd(e,t){let n=la(e);if(_a(e))return n;if(!pa(e)){let t=Oa(e);for(;t&&!Ta(t);){if(fa(t)&&!Rd(t))return t;t=Oa(t)}return n}let r=zd(e,t);for(;r&&ga(r)&&Rd(r);)r=zd(r,t);return r&&Ta(r)&&Rd(r)&&!Sa(r)?n:r||Ca(e)||n}let Vd=async function(e){let t=this.getOffsetParent||Bd,n=this.getDimensions,r=await n(e.floating);return{reference:Ld(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Hd(e){return Ea(e).direction===`rtl`}let Ud={convertOffsetParentRelativeRectToViewportRelativeRect:Od,getDocumentElement:ua,getClippingRect:Fd,getOffsetParent:Bd,getElementRects:Vd,getClientRects:kd,getDimensions:Id,getScale:xd,isElement:fa,isRTL:Hd};function Wd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Gd(e,t,n){let r=null,i,a=ua(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=as(d),h=as(a.clientWidth-(u+f)),g=as(a.clientHeight-(d+p)),_=as(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:rs(0,ns(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Wd(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=la(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Kd(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=bd(e),u=i||a?[...l?Aa(l):[],...t?Aa(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Gd(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Td(e):null;c&&g();function g(){let t=Td(e);h&&!Wd(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}let qd=hd,Jd=gd,Yd=fd,Xd=vd,Zd=_d,Qd=(e,t,n)=>{let r=/* @__PURE__ */ new Map,i=n??{},a={...Ud,...i.platform,_c:r};return dd(e,t,{...i,platform:a})};var $d=typeof document<`u`?y.useLayoutEffect:function(){};function ef(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!ef(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!ef(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function tf(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function nf(e,t){let n=tf(e);return Math.round(t*n)/n}function rf(e){let t=y.useRef(e);return $d(()=>{t.current=e}),t}function af(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=y.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=y.useState(r);ef(f,r)||p(r);let[m,h]=y.useState(null),[g,_]=y.useState(null),v=y.useCallback(e=>{e!==w.current&&(w.current=e,h(e))},[]),x=y.useCallback(e=>{e!==T.current&&(T.current=e,_(e))},[]),S=a||m,C=o||g,w=y.useRef(null),T=y.useRef(null),E=y.useRef(u),D=c!=null,O=rf(c),k=rf(i),A=rf(l),j=y.useCallback(()=>{if(!w.current||!T.current)return;let e={placement:t,strategy:n,middleware:f};k.current&&(e.platform=k.current),Qd(w.current,T.current,e).then(e=>{let t={...e,isPositioned:A.current!==!1};M.current&&!ef(E.current,t)&&(E.current=t,b.flushSync(()=>{d(t)}))})},[f,t,n,k,A]);$d(()=>{l===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let M=y.useRef(!1);$d(()=>(M.current=!0,()=>{M.current=!1}),[]),$d(()=>{if(S&&(w.current=S),C&&(T.current=C),S&&C){if(O.current)return O.current(S,C,j);j()}},[S,C,j,O,D]);let N=y.useMemo(()=>({reference:w,floating:T,setReference:v,setFloating:x}),[v,x]),P=y.useMemo(()=>({reference:S,floating:C}),[S,C]),F=y.useMemo(()=>{let e={position:n,left:0,top:0};if(!P.floating)return e;let t=nf(P.floating,u.x),r=nf(P.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...tf(P.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,P.floating,u.x,u.y]);return y.useMemo(()=>({...u,update:j,refs:N,elements:P,floatingStyles:F}),[u,j,N,P,F])}let of=(e,t)=>{let n=qd(e);return{name:n.name,fn:n.fn,options:[e,t]}},sf=(e,t)=>{let n=Jd(e);return{name:n.name,fn:n.fn,options:[e,t]}},cf=(e,t)=>({fn:Zd(e).fn,options:[e,t]}),lf=(e,t)=>{let n=Yd(e);return{name:n.name,fn:n.fn,options:[e,t]}},uf=(e,t)=>{let n=Xd(e);return{name:n.name,fn:n.fn,options:[e,t]}},df={...Iu,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,appliedTriggerProps:(e,t)=>t?e.activeTriggerProps:void 0,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin};var ff=class extends Du{constructor(e,t,n){let r=new mu;super(pf(e,r,t,n),mf(r),df)}setOpen=(e,t)=>{cu(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,Q(mo,e))}};function pf(e,t,n,r=!1){return{...Au(t,n,r),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:`none`,disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e}}function mf(e){return{popupRef:/*#__PURE__*/ y.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}let hf=Di(function(e){let{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:a=`none`,actionsRef:o,onOpenChange:s,onOpenChangeComplete:c,handle:l,triggerId:u,defaultTriggerId:d=null,children:f}=e,p=nu((e,t)=>new ff({open:n,openProp:r,activeTriggerId:d,triggerIdProp:u},e,t));p.useControlledProp(`openProp`,r),p.useControlledProp(`triggerIdProp`,u),p.useContextCallback(`onOpenChange`,s),p.useContextCallback(`onOpenChangeComplete`,c);let m=p.useState(`open`),h=!t&&m,g=p.useState(`activeTriggerId`),_=p.useState(`mounted`),v=p.useState(`payload`);p.useSyncedValues({trackCursorAxis:a,disableHoverablePopup:i,disabled:t}),uu(p,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:b,transitionStatus:x}=du(h,p),S=p.useState(`isInstantPhase`),C=p.useState(`instantType`),w=p.useState(`lastOpenChangeReason`),T=y.useRef(null);X(()=>{m&&t&&p.setOpen(!1,Q(`disabled`))},[m,t,p]),X(()=>{x===`ending`&&w===`none`||x!==`ending`&&S?(C!==`delay`&&(T.current=C),p.set(`instantType`,`delay`)):T.current!==null&&(p.set(`instantType`,T.current),T.current=null)},[x,S,w,C,p]),X(()=>{h&&(g??p.set(`payload`,void 0))},[p,g,h]),y.useImperativeHandle(o,()=>({unmount:b,close:()=>p.setOpen(!1,Q(ko))}),[b,p]);let E=h||_||!t&&a!==`none`;return/*#__PURE__*/ (0,A.jsxs)(Fi.Provider,{value:p,children:[l&&/*#__PURE__*/ (0,A.jsx)(ru,{handle:l,store:p}),E&&/*#__PURE__*/ (0,A.jsx)(gf,{store:p,disabled:t,trackCursorAxis:a}),typeof f==`function`?f({payload:v}):f]})});function gf({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=Fl(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=Ml(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=y.useMemo(()=>Fc(a.reference,i.reference),[a.reference,i.reference]);return fu(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??Mi}),null}function _f(e){return Dc(e,`base-ui`)}let vf=/*#__PURE__*/ y.createContext(void 0);function yf(){return y.useContext(vf)}let bf=`data-base-ui-tooltip-trigger`;function xf(e){let t=Pa(e);return fa(t)?t:null}let Sf=Oi(function(e,t){let{render:n,className:r,style:i,handle:a,payload:o,disabled:s,delay:c,closeOnClick:l=!0,closeDelay:u,id:d,...f}=e,p=Ii(!0),m=Lu(a)??p;if(!m)throw Error(Pi(82));let h=_f(d),g=m.useState(`isTriggerActive`,h),_=m.useState(`isOpenedByTrigger`,h),v=m.useState(`floatingRootContext`),b=y.useRef(null),x=u??0,{registerTrigger:S,isMountedByThisTrigger:C}=lu(h,b,m,{payload:o,closeOnClick:l,closeDelay:x}),w=yf(),{activeIdRef:T,delayRef:E,isInstantPhase:D,hasProvider:O}=Mo(v,{open:_}),k=Gu(v);m.useSyncedValue(`isInstantPhase`,D);let A=m.useState(`disabled`),j=s??A,M=Vo(j),N=m.useState(`trackCursorAxis`),P=m.useState(`disableHoverablePopup`),F=y.useRef(!1),I=zi(),L=y.useRef(void 0);function R(){return O&&T.current!=null?0:c??w??600}function z(e){let t=b.current;if(!t||!e)return!1;let n=Na(e,`[${bf}]`);return n!==null&&n!==t&&Z(t,n)}function B(e){let t=z(e);return F.current=t,t&&(k.openChangeTimeout.clear(),k.restTimeout.clear(),k.restTimeoutPending=!1,I.clear()),t}let V=Ju(v,{enabled:!j,mouseOnly:!0,move:!1,handleClose:!P&&N!==`both`?cd():null,restMs:R,delay(){return u==null&&O?{close:so(E.current,`close`)}:{close:x}},triggerElementRef:b,isActiveTrigger:g,isClosing:()=>m.select(`transitionStatus`)===`ending`,shouldOpen(){return!F.current}}),H=Bu(v,{enabled:!j}).reference,U=e=>{let t=F.current,n=xf(e),r=B(n),i=b.current,a=i&&n&&Z(i,n);if(r&&m.select(`open`)&&m.select(`lastOpenChangeReason`)===`trigger-hover`)m.setOpen(!1,Q(ho,e));else if(t&&!r&&a&&!M.current&&!m.select(`open`)&&i&&aa(L.current)){let t=()=>{F.current||M.current||m.select(`open`)||m.setOpen(!0,Q(ho,e,i))},n=R();n===0?(I.clear(),t()):I.start(n,t)}},ee=m.useState(`appliedTriggerProps`,C||N!==`none`);return Jc(`button`,e,{state:{open:_},ref:[t,S,b],props:[V,H,ee,{onMouseOver(e){U(e.nativeEvent)},onFocus(e){z(xf(e.nativeEvent))&&e.preventBaseUIHandler()},onMouseLeave(){F.current=!1,I.clear(),L.current=void 0},onPointerEnter(e){L.current=e.pointerType},onPointerDown(e){L.current=e.pointerType,m.set(`closeOnClick`,l),l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},onClick(e){l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},id:h,[Za]:j?``:void 0,[bf]:j?void 0:``},f],stateAttributesMapping:qa})}),Cf=/*#__PURE__*/ y.createContext(void 0);function wf(){let e=y.useContext(Cf);if(e===void 0)throw Error(Pi(70));return e}let Tf=/*#__PURE__*/ y.forwardRef(function(e,t){let{children:n,container:r,className:i,render:a,style:o,...s}=e,{node:c,subtree:l}=ll({container:r,ref:t,componentProps:e,elementProps:s});return!l&&!c?null:/*#__PURE__*/ (0,A.jsxs)(y.Fragment,{children:[l,c&&/*#__PURE__*/ b.createPortal(n,c)]})}),Ef=/*#__PURE__*/ y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return Ii().useState(`mounted`)||n?/*#__PURE__*/ (0,A.jsx)(Cf.Provider,{value:n,children:/*#__PURE__*/ (0,A.jsx)(Tf,{ref:t,...r})}):null}),Df=/*#__PURE__*/ y.createContext(void 0);function Of(){let e=y.useContext(Df);if(e===void 0)throw Error(Pi(71));return e}function kf(e){let{nodeId:t,externalTree:n,rootContext:r}=e,i=r.useState(`referenceElement`),a=r.useState(`floatingElement`),o=r.useState(`domReferenceElement`),s=r.useState(`open`),c=r.useState(`floatingId`),[l,u]=y.useState(null),d=y.useRef(null),f=gl(n),p=y.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),m=af({...e,elements:{...p,...l&&{reference:l}}}),h=y.useCallback(e=>{let t=fa(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),m.refs.setReference(t)},[m.refs]),g=y.useMemo(()=>({...m.refs,setPositionReference:h,domReference:d}),[m.refs,h]),_=y.useMemo(()=>({...m.elements,domReference:o}),[m.elements,o]),v=y.useMemo(()=>({...m,dataRef:r.context.dataRef,open:s,onOpenChange:r.setOpen,events:r.context.events,floatingId:c,refs:g,elements:_,nodeId:t,rootStore:r}),[m,g,_,t,r,s,c]);return X(()=>{o&&(d.current=o)},[o]),X(()=>{r.context.dataRef.current.floatingContext=v;let e=f?.nodesRef.current.find(e=>e.id===t);e&&(e.context=v)}),y.useMemo(()=>({...m,context:v,refs:g,elements:_,rootStore:r}),[m,g,_,v,r])}let Af=/*#__PURE__*/ y.createContext(void 0);function jf(){return y.useContext(Af)?.direction??`ltr`}let Mf=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=ls(e,t)||{};if(l==null)return{};let d=Ds(u),f={x:n,y:r},p=hs(i),m=ps(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=s.floating[y]||a.floating[m],C=b/2-x/2,w=S/2-h[m]/2-1,T=Math.min(d[_],w),E=Math.min(d[v],w),D=T,O=S-h[m]-E,k=S/2-h[m]/2+C,A=cs(D,k,O),j=!c.arrow&&ds(i)!=null&&k!==A&&a.reference[m]/2-(k<D?T:E)-h[m]/2<0,M=j?k<D?k-D:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),Nf=(e,t)=>{let{name:n,fn:r}=Mf(e);return{name:n,fn:r,options:[e,t]}},Pf={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},Ff={sideX:`left`,sideY:`top`},If=`--available-width`,Lf=`--available-height`;function Rf(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function zf(e,t,n){let{rects:r,placement:i}=e;return{side:Rf(t,us(i),n),align:ds(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function Bf(e){return Vf(e,kf)}function Vf(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:b,adaptiveOrigin:x,lazyFlip:S=!1,externalTree:C}=e,w=_.side||`flip`,T=_.align||`flip`,E=_.fallbackAxisSide||`end`,D=v?.crossAxis??!1,O=v?.rootBoundary,k=typeof n==`function`?n:void 0,A=$(k),j=k?A:n,M=Vo(n),N=Vo(g),P=jf()===`rtl`,[F,I]=y.useState(null);!g&&F!==null&&I(null);let L=S===`placement`,R=F?us(F):null,z=F&&L?ds(F)||`center`:null,B=R||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":P?`left`:`right`,"inline-start":P?`right`:`left`}[i],V=z||o,H=V===`center`?B:`${B}-${V}`,U=l;typeof U==`number`?U={top:U,right:U,bottom:U,left:U}:U&&={top:U.top||0,right:U.right||0,bottom:U.bottom||0,left:U.left||0};let ee=+(i===`bottom`),te=+(i===`top`),ne=+(i===`right`),W=+(i===`left`),re={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:U},ie=y.useRef(null),G=Vo(a),K=Vo(s),q=typeof a==`function`?0:a,ae=typeof s==`function`?0:s,oe=[];p&&oe.push(p),oe.push(of(e=>{let t=zf(e,i,P),n=typeof G.current==`function`?G.current(t):G.current,r=typeof K.current==`function`?K.current(t):K.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[q,ae,P,i]));let se=T===`none`&&w!==`shift`,ce=!se&&(u||D||w===`shift`),le=w===`none`?null:lf({...re,padding:{top:U.top+1+ee,right:U.right+1+W,bottom:U.bottom+1+te,left:U.left+1+ne},mainAxis:!D&&w===`flip`,crossAxis:T===`flip`&&`alignment`,fallbackAxisSideDirection:E}),J=se?null:sf({...re,rootBoundary:O,mainAxis:T!==`none`,crossAxis:ce,limiter:u||D?void 0:cf(e=>{if(!ie.current)return{};let{width:t,height:n}=ie.current.getBoundingClientRect(),r=ms(us(e.placement)),i=r===`y`?t:n,a=r===`y`?U.left+U.right:U.top+U.bottom;return{offset:i/2+a/2}})},[re,u,D,O,U,T]);w===`shift`||T===`shift`||V===`center`?oe.push(J,le):oe.push(le,J),oe.push(uf({...re,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!N.current)return;let i=e.style;i.setProperty(If,`${t}px`),i.setProperty(Lf,`${n}px`);let a=la(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(`--anchor-width`,`${u}px`),i.setProperty(`--anchor-height`,`${d}px`)}}),Nf(e=>({element:ie.current||Zo(e.elements.floating).createElement(`div`),padding:ie.current?d:0}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=us(r),u=ds(r),d=ms(l)===`y`,f=ie.current,p=typeof a==`function`?a(zf(e,i,P)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return ce&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(`--transform-origin`,d?`${m} ${h}`:`${h} ${m}`),{}}},Pf,x),X(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let ue=y.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:de,elements:fe,x:pe,y:me,middlewareData:he,update:ge,placement:_e,context:ve,isPositioned:ye,floatingStyles:be}=t({rootContext:h,open:m?g:void 0,placement:H,middleware:oe,strategy:r,whileElementsMounted:m?void 0:(...e)=>Kd(...e,ue),nodeId:b,externalTree:C}),{sideX:xe,sideY:Se}=he.adaptiveOrigin||Ff,Ce=ye?r:`fixed`,we=y.useMemo(()=>{let e;return e=ye?x?{position:Ce,[xe]:pe,[Se]:me}:{...be,position:Ce}:{position:Ce,top:0,left:0},e[If]=`100vw`,e[Lf]=`100vh`,ye||(e.opacity=0),e},[x,Ce,xe,pe,Se,me,be,ye]),Te=y.useRef(null);X(()=>{if(!g)return;let e=M.current,t=typeof e==`function`?e():e,n=(Hf(t)?t.current:t)||null;n!==Te.current&&(de.setPositionReference(n),Te.current=n)},[g,de,j,M]),y.useEffect(()=>{if(!g)return;let e=M.current;typeof e!=`function`&&Hf(e)&&e.current!==Te.current&&(de.setPositionReference(e.current),Te.current=e.current)},[g,de,j,M]),y.useEffect(()=>{if(m&&g&&fe.reference&&fe.floating)return Kd(fe.reference,fe.floating,ge,ue)},[m,g,fe,ge,ue]);let Ee=us(_e),De=Rf(i,Ee,P),Oe=ds(_e)||`center`,ke=!!he.hide?.referenceHidden;X(()=>{S&&g&&ye&&(Ee!==B||L&&Oe!==V)&&I(_e)},[S,L,g,ye,_e,Ee,Oe,B,V]);let Ae=y.useMemo(()=>({position:`absolute`,top:he.arrow?.y,left:he.arrow?.x}),[he.arrow]),je=he.arrow?.centerOffset!==0;return y.useMemo(()=>({positionerStyles:we,arrowStyles:Ae,arrowRef:ie,arrowUncentered:je,side:De,align:Oe,physicalSide:Ee,anchorHidden:ke,refs:de,context:ve,isPositioned:ye,update:ge}),[we,Ae,ie,je,De,Oe,Ee,ke,de,ve,ye,ge])}function Hf(e){return e!=null&&`current`in e}function Uf(e){return e===`starting`?tl:Mi}function Wf(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),Jc(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},Uf(r),i],stateAttributesMapping:Ya})}let Gf=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`top`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=il,style:g,..._}=e,v=Ii(),b=wf(),x=v.useState(`open`),S=v.useState(`mounted`),C=v.useState(`trackCursorAxis`),w=v.useState(`disableHoverablePopup`),T=v.useState(`floatingRootContext`),E=v.useState(`instantType`),D=v.useState(`transitionStatus`),O=Bf({anchor:i,positionMethod:a,floatingRootContext:T,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,collisionBoundary:u,collisionPadding:d,sticky:p,arrowPadding:f,disableAnchorTracking:m,keepMounted:b,collisionAvoidance:h,adaptiveOrigin:v.useState(`adaptiveOrigin`)}),k=Wf(e,y.useMemo(()=>({open:x,side:O.side,align:O.align,anchorHidden:O.anchorHidden,instant:C===`none`?E:`tracking-cursor`}),[x,O.side,O.align,O.anchorHidden,C,E]),{styles:O.positionerStyles,transitionStatus:D,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!S,inert:!x||C===`both`||w});return/*#__PURE__*/ (0,A.jsx)(Df.Provider,{value:O,children:k})}),Kf=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Ii(),{side:s,align:c}=Of(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`disabled`),h=o.useState(`closeDelay`);Ql({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),Ku(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return Jc(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[eu,f,Uf(d),a],stateAttributesMapping:Xa})}),qf=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Ii(),{arrowRef:s,side:c,align:l,arrowUncentered:u,arrowStyles:d}=Of();return Jc(`div`,e,{state:{open:o.useState(`open`),side:c,align:l,uncentered:u,instant:o.useState(`instantType`)},ref:[t,s],props:[{style:d,"aria-hidden":!0},a],stateAttributesMapping:Ya})});function Jf(e){return Oc(19)?e:e?`true`:void 0}function Yf(e){let[t,n]=y.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}let Xf=/* @__PURE__ */ new Set;function Zf({label:e,side:t=`top`,describe:n=!0,wrap:r=!1,disabled:i=!1,children:a}){let o=y.useId(),[s,c]=y.useState(!1),l=y.useCallback(()=>c(!1),[]),u=s&&!i;return y.useEffect(()=>{if(!u)return;let e=e=>{let t=e.target;t instanceof Element&&t.closest(`[data-ui-tip="${o}"]`)||l()};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`scroll`,l,!0),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`scroll`,l,!0)}},[u,l,o]),y.useEffect(()=>{if(u){for(let e of Xf)e!==l&&e();return Xf.add(l),()=>{Xf.delete(l)}}},[u,l]),/* @__PURE__ */ (0,A.jsxs)(hf,{disabled:i,open:u,onOpenChange:c,children:[/* @__PURE__ */ (0,A.jsx)(Sf,{delay:0,render:a,"aria-describedby":n&&!i?o:void 0,onBlur:l,"data-ui-tip":o}),n&&!i?/* @__PURE__ */ (0,A.jsx)(`span`,{id:o,hidden:!0,children:e}):null,/* @__PURE__ */ (0,A.jsx)(Ef,{children:/* @__PURE__ */ (0,A.jsx)(Gf,{side:t,sideOffset:8,className:`ui-tooltip-positioner`,children:/* @__PURE__ */ (0,A.jsxs)(Kf,{className:r?`ui-tooltip is-wrap`:`ui-tooltip`,children:[e,/* @__PURE__ */ (0,A.jsx)(qf,{className:`ui-tooltip-arrow`})]})})})]})}Fe(),Pr(),Mn(),ti(Pe,Nr,jn);let Qf=e=>!!e&&typeof e==`object`&&!y.isValidElement(e)&&!Array.isArray(e)&&typeof e.name==`string`;function $f({brand:e,collapsed:t}){let n=Qf(e)?e:typeof e==`string`?{name:e}:null;if(G(!n&&t,`SideNav`,`brand 是一個元素,收合時讀不出哪部分是 logo,只能整塊藏起來。改傳 brand={{ mark, name, href }}:收合時顯示 mark,展開時加上名稱。`),!n)return/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-nav-brand`,children:t?null:e});let r=/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-nav-mark`,"aria-hidden":`true`,children:n.mark??/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-nav-monogram`,children:Array.from(n.name)[0]})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-nav-brand-name`,children:n.name})]}),i=t?n.name:void 0;return/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-nav-brand has-mark`,children:n.href?/* @__PURE__ */ (0,A.jsx)(`a`,{className:`ui-nav-brand-link`,href:n.href,onClick:n.onClick,"aria-label":i,children:r}):n.onClick?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-nav-brand-link`,onClick:n.onClick,"aria-label":i,children:r}):/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-nav-brand-link`,"aria-label":i,role:i?`img`:void 0,children:r})})}function ep({sections:e,value:t,onChange:n,collapsed:r=!1,onToggle:i,onPin:a,pinned:o=!1,brand:s,label:c,className:l}){let u=y.useRef({}),d=y.useRef(null),[f,p]=y.useState({top:0,bottom:0,show:!1,down:!0}),m=y.useRef(null),[h,g]=gi(),_=y.useRef(t);y.useEffect(()=>{if(t===_.current)return;_.current=void 0;let n=e.flatMap(e=>e.items.flatMap(e=>[e,...e.children??[]])).find(e=>e.id===t);n&&bi(n.label)},[t]);let[v,b]=y.useState({}),x=Object.keys(v).filter(e=>v[e]).join();y.useLayoutEffect(()=>{let n=u.current[t];if(!n){let r=e.flatMap(e=>e.items).find(e=>e.children?.some(e=>e.id===t));n=r?u.current[r.id]:null}let r=d.current;if(!n||!r)return;let i=n.getBoundingClientRect().top-r.getBoundingClientRect().top,a=Math.round(i)+8,o=Math.round(r.clientHeight-i-n.offsetHeight)+8,s=m.current;s&&s.top===a&&s.bottom===o||(s&&s.top!==a&&g(),m.current={top:a,bottom:o},p({top:a,bottom:o,show:!0,down:!s||a>=s.top}))},[t,r,x,e,g]);let S=(e,i)=>{let a=e.children??[],o=a.length>0&&!r,s=!v[e.id],c=t===e.id||(!o||!s)&&a.some(e=>e.id===t),l=[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-nav-row`,children:[/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,ref:t=>{u.current[e.id]=t},className:M(`ui-nav-item`,i&&`is-sub`,c&&`is-selected`),"aria-current":c?`page`:void 0,"aria-expanded":o?s:void 0,"aria-label":r?e.label:void 0,onClick:()=>o?b({...v,[e.id]:s}):n?.(a[0]?.id??e.id),children:[e.icon&&!i?/* @__PURE__ */ (0,A.jsx)(fi,{icon:e.icon,size:22,filled:c,className:`ui-nav-icon`}):null,r?null:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-nav-label`,children:e.label}),o?/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-right`,size:16,className:M(`ui-nav-chev`,s&&`is-open`)}):null]}),r?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-nav-tip`,role:`tooltip`,children:e.label}):null]},e.id)];if(o&&s)for(let e of a)l.push(...S(e,!0));return l},C=w(r?`展開側邊欄`:`收合側邊欄`);return/* @__PURE__ */ (0,A.jsxs)(`aside`,{className:M(`ui-sidenav`,r&&`is-collapsed`,l),children:[s?/* @__PURE__ */ (0,A.jsx)($f,{brand:s,collapsed:r}):null,/* @__PURE__ */ (0,A.jsx)(`nav`,{className:`ui-nav-list`,"aria-label":c||w(`主要導覽`),children:/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:d,className:`ui-nav-inner`,children:[f.show?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-nav-bar`,"aria-hidden":`true`,style:{top:f.top,bottom:f.bottom,transform:h?`scaleX(.7)`:`none`,transition:hi(`top`,`bottom`,f.down)}}):null,e.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(y.Fragment,{children:[t>0?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-nav-divider`,role:`separator`}):null,e.items.flatMap(e=>S(e,!1))]},t))]})}),i||a?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-nav-foot`,children:[a?/* @__PURE__ */ (0,A.jsx)(Zf,{label:w(o?`取消釘選`:`釘選側邊欄`),side:`right`,describe:!1,children:/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:M(`ui-nav-collapse`,`ui-nav-pin`,o&&`is-on`),"aria-pressed":o,"aria-label":w(o?`取消釘選`:`釘選側邊欄`),onClick:a,children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`push-pin`,size:20,filled:o})})}):null,i?/* @__PURE__ */ (0,A.jsx)(Zf,{label:C,side:`right`,describe:!1,children:/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-nav-collapse`,"aria-label":C,onClick:i,children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`sidebar-simple`,size:20})})}):null]}):null]})}function tp({items:e,className:t}){return/* @__PURE__ */ (0,A.jsx)(`nav`,{className:M(`ui-crumb`,t),"aria-label":w(`路徑`),children:/* @__PURE__ */ (0,A.jsx)(`ol`,{children:e.map((t,n)=>{let r=n===e.length-1;return/* @__PURE__ */ (0,A.jsxs)(`li`,{children:[r?/* @__PURE__ */ (0,A.jsx)(`span`,{"aria-current":`page`,children:t.label}):t.href?/* @__PURE__ */ (0,A.jsx)(`a`,{href:t.href,children:t.label}):/* @__PURE__ */ (0,A.jsx)(`span`,{children:t.label}),r?null:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-crumb-sep`,"aria-hidden":`true`,children:`›`})]},n)})})})}ir(),ti(rr);function np({label:e,icon:t,className:n,tooltip:r=!0,filled:i,hint:a,variant:o,...s}){let c=y.useId(),l=/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,...s,className:M(`ui-iconbtn`,o===`quiet`&&`is-quiet`,a&&`has-hint`,n),"aria-label":e,"aria-describedby":a?c:s[`aria-describedby`],children:[/* @__PURE__ */ (0,A.jsx)(fi,{icon:t,filled:i}),a&&/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-iconbtn-dot`,"aria-hidden":`true`})]}),u=r?/* @__PURE__ */ (0,A.jsx)(Zf,{label:e,describe:!1,children:l}):l;return a?/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-iconbtn-hintbox`,children:[u,/* @__PURE__ */ (0,A.jsx)(rp,{id:c,hint:a})]}):u}function rp({id:e,hint:t}){let n=y.useRef(null),[r,i]=y.useState(null);y.useLayoutEffect(()=>{let e=n.current;if(!e)return;let t=()=>{let t=e.parentElement?.getBoundingClientRect();if(!t)return;let n=Math.floor(t.left-12-8);if(n>=180)return i({room:n});let r=Math.min(320,window.innerWidth-32),a=t.left+t.width-r,o=Math.max(16,Math.min(a,window.innerWidth-16-r));i({room:n,left:Math.round(o-t.left),arrow:Math.round(t.left+t.width/2-o-6)})};return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[]);let a=r!=null&&r.room<180;return/* @__PURE__ */ (0,A.jsxs)(`span`,{ref:n,className:M(`ui-hint`,a&&`is-below`),id:e,role:`status`,style:r==null?void 0:a?{left:r.left,right:`auto`,"--hint-arrow":r.arrow+`px`}:{maxWidth:Math.min(320,r.room)},children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-hint-text`,children:t.text}),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-hint-go`,onClick:t.onAction,children:t.action??w(`開始`)}),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-hint-x`,"aria-label":w(`關閉提示`),onClick:t.onDismiss,children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`,size:16})})]})}rn(),cn(),ti(nn,sn);function ip({title:e,breadcrumb:t,onSearch:n,searchLabel:r,children:i,onMenu:a,className:o}){let s=H(B);return/* @__PURE__ */ (0,A.jsxs)(`header`,{className:M(`ui-topbar`,o),children:[a?/* @__PURE__ */ (0,A.jsx)(np,{className:`ui-topbar-menu`,icon:`list-bullets`,label:w(`開啟導覽`),onClick:a}):null,e?/* @__PURE__ */ (0,A.jsx)(`h1`,{className:`ui-topbar-title`,children:e}):null,t?/* @__PURE__ */ (0,A.jsx)(tp,{items:t}):null,/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-topbar-end`,children:[n===!1?null:/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:`ui-search`,"data-tour":`search`,onClick:n,"aria-keyshortcuts":z?`Meta+K`:`Control+K`,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`magnifying-glass`,size:16}),/* @__PURE__ */ (0,A.jsx)(`span`,{children:r||w(`搜尋`)}),s?null:/* @__PURE__ */ (0,A.jsx)(`kbd`,{children:V})]}),/* @__PURE__ */ (0,A.jsx)(np,{className:`ui-search-icon`,"data-tour":`search`,icon:`magnifying-glass`,label:s?w(`搜尋`):w(`搜尋({k})`,{k:V}),onClick:n})]}),i]})]})}function ap({items:e,value:t,onChange:n,label:r,labels:i=!0,className:a}){let o=Math.max(0,e.findIndex(e=>e.id===t)),[s,c]=y.useState(!0),l=100/Math.max(1,e.length);return/* @__PURE__ */ (0,A.jsxs)(`nav`,{className:M(`ui-tabbar`,i&&`has-labels`,a),"aria-label":r||w(`主要導覽`),children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tabbar-pill`,"aria-hidden":`true`,style:{left:`calc(${o*l+l/2}% - 28px)`,right:`calc(${100-o*l-l/2}% - 28px)`,transition:hi(`left`,`right`,s)}}),e.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-tabbar-item`,t===o&&`is-selected`),"aria-label":i?void 0:e.label,"aria-current":t===o?`page`:void 0,onClick:()=>{t!==o&&c(t>o),n?.(e.id)},children:[/* @__PURE__ */ (0,A.jsx)(fi,{icon:e.icon,size:22,filled:t===o}),i?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tabbar-label`,children:e.label}):null]},e.id))]})}let op=/*#__PURE__*/ y.createContext(void 0);function sp(e){let t=y.useContext(op);if(!e&&t===void 0)throw Error(Pi(27));return t}let cp=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=sp(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return Jc(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:Xa,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),lp=/*#__PURE__*/ y.createContext(void 0);function up(e=!1){let t=y.useContext(lp);if(t===void 0&&!e)throw Error(Pi(16));return t}function dp(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:y.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function fp(e,t,{detail:n=0,pointerType:r=``}={}){e.dispatchEvent(new(la(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,pointerType:r,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function pp(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=y.useRef(null),s=up(!0),c=a??s!==void 0,{props:l}=dp({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=y.useCallback(()=>{let e=o.current;mp(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return X(u,[u]),{getButtonProps:y.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return Fc({onClick(e){t?e.preventDefault():n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(Gc(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=mp(r),s=!i&&hp(r),l=n&&(i?a:!s),u=e.key===`Enter`,d=e.key===` `,f=r.getAttribute(`role`),p=f?.startsWith(`menuitem`)||f===`option`||f===`gridcell`;if(n&&c&&d){if(e.defaultPrevented&&p)return;e.preventDefault(),(!i||a)&&(e.preventBaseUIHandler(),fp(r,e))}else!l||i||!d&&!u?n&&s&&d&&e.preventDefault():e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),fp(r,e)))},onKeyUp(e){t||(Gc(e),a?.(e),e.target===e.currentTarget&&i&&c&&mp(e.currentTarget)&&e.key===` `?e.preventDefault():e.baseUIHandlerPrevented||e.target!==e.currentTarget||i||c||e.defaultPrevented||e.key!==` `||(e.preventBaseUIHandler(),fp(e.currentTarget,e)))},onPointerDown(e){t?e.preventDefault():s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:$(e=>{o.current=e,u()})}}function mp(e){return pa(e)&&e.tagName===`BUTTON`}function hp(e){return pa(e)&&e.tagName===`A`&&!!e.href}let gp=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=sp(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=pp({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,Q(vo,e.nativeEvent))}return Jc(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})}),_p=/*#__PURE__*/ y.createContext(void 0);function vp(){let e=y.useContext(_p);if(e===void 0)throw Error(Pi(26));return e}let yp=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),bp={...Ya,...Ba,nestedDialogOpen(e){return e?{"data-nested-dialog-open":``}:null}},xp=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=sp(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);vp(),Ql({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?tu(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=Jc(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...eu,hidden:!m,onKeyDown(e){yp.has(e.key)&&e.stopPropagation()},style:{"--nested-dialogs":g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:bp});return/*#__PURE__*/ (0,A.jsx)(Ol,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})}),Sp=/*#__PURE__*/ y.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return/*#__PURE__*/ (0,A.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})}),Cp=/*#__PURE__*/ y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=sp(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?/*#__PURE__*/ (0,A.jsx)(_p.Provider,{value:n,children:/*#__PURE__*/ (0,A.jsxs)(ul,{ref:t,...r,children:[a&&o===!0&&/*#__PURE__*/ (0,A.jsx)(Sp,{ref:i.context.internalBackdropRef,inert:Jf(!s)}),e.children]})}):null}),wp={},Tp={},Ep=``;function Dp(e,t){return ha(e)?e:t}function Op(e,t,n){return/hidden|clip/.test(e.getComputedStyle(Dp(t,n)).overflowY)}function kp(e){if(typeof document>`u`)return!1;let t=Zo(e);return la(t).innerWidth-t.documentElement.clientWidth>0}function Ap(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=Zo(e),n=t.documentElement,r=t.body,i=Dp(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function jp(e){let t=Zo(e),n=t.documentElement,r=t.body,i=Dp(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function Mp(e){let t=Zo(e),n=t.documentElement,r=t.body,i=la(n),a=0,o=0,s=!1,c=Yo.create();if(Zi&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,wp={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},Ep=n.style.scrollBehavior,Tp={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=Dp(n,r);s=Ap(e),s?(n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`):(Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`)}function u(){Object.assign(n.style,wp),Object.assign(r.style,Tp),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=Ep)}function d(){u(),c.request(l)}l();let f=No(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}let Np=new class{lockCount=0;restore=null;timeoutLock=Ri.create();timeoutUnlock=Ri.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=Zo(e),n=t.documentElement,r=t.body,i=la(n);if(Op(i,n,r)){let t=new i.MutationObserver(()=>{Op(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=Ki||!kp(e);this.restore=a?jp(e):Mp(e)}};function Pp(e=!0,t=null){X(()=>{if(e)return Np.acquire(t)},[e,t])}function Fp({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`mounted`),a=e.useState(`disablePointerDismissal`),o=e.useState(`modal`),s=e.useState(`popupElement`),c=e.useState(`floatingRootContext`),[l,u]=y.useState(0),[d,f]=y.useState(0),p=l===0,m=Fl(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:o===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=Pa(t);if(p&&!a){if(o){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||Z(n,s)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:p});return Pp(r&&o===!0,s),e.useContextCallback(`onNestedDialogOpen`,(t,n)=>{(e.select(`open`)||e.select(`mounted`))&&(u(t),f(n))}),X(()=>{!r&&!i&&(u(0),f(0))},[r,i]),X(()=>(t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(l+1,d+ +!!n),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,l,d,t]),fu(e,{activeTriggerProps:m.reference,inactiveTriggerProps:m.trigger,popupProps:m.floating,nestedOpenDialogCount:l,nestedOpenDrawerCount:d}),null}let Ip={...Iu,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role};var Lp=class extends Du{constructor(e,t,n){let r=new mu,i=Rp(e,r,t,n);super(i,zp(r),Ip)}setOpen=(e,t)=>{t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled||(this.state.floatingRootContext.dispatchOpenChange(e,t),this.update(ou(this.state,e,t.trigger)))}};function Rp(e,t,n,r=!1){return{...Au(t,n,r),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}function zp(e){return{popupRef:/*#__PURE__*/ y.createRef(),backdropRef:/*#__PURE__*/ y.createRef(),internalBackdropRef:/*#__PURE__*/ y.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function Bp(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:d,defaultTriggerId:f=null}=t,p=e===`drawer`,m=e===`alert-dialog`,h=m?!0:c,g=m||s,_=m?`alertdialog`:`dialog`,v=sp(!0),b={modal:h,disablePointerDismissal:g,nested:v!=null,role:_},x=nu((e,t)=>new Lp({open:i,openProp:r,activeTriggerId:f,triggerIdProp:d,...b},e,t),!0);x.useControlledProp(`openProp`,r),x.useControlledProp(`triggerIdProp`,d),x.useSyncedValues(b),x.useContextCallback(`onOpenChange`,a),x.useContextCallback(`onOpenChangeComplete`,o);let S=x.useState(`open`),C=x.useState(`mounted`),w=x.useState(`payload`);pu(x,S),uu(x);let{forceUnmount:T}=du(S,x);y.useImperativeHandle(l,()=>({unmount:T,close:()=>x.setOpen(!1,Q(ko))}),[T,x]);let E=S||C||u!=null;return/*#__PURE__*/ (0,A.jsxs)(op.Provider,{value:x,children:[u&&/*#__PURE__*/ (0,A.jsx)(ru,{handle:u,store:x}),E&&/*#__PURE__*/ (0,A.jsx)(Fp,{store:x,parentContext:v?.context,isDrawer:p}),typeof n==`function`?n({payload:w}):n]})}let Vp=Di(function(e){return Bp(`dialog`,e)}),Hp=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=vp(),c=sp(),l=c.useState(`open`),u=c.useState(`nested`),d=c.useState(`transitionStatus`),f=c.useState(`nestedOpenDialogCount`),p=c.useState(`mounted`),m=c.useStateSetter(`viewportElement`);return Jc(`div`,e,{enabled:s||p,state:{open:l,nested:u,transitionStatus:d,nestedDialogOpen:f>0},ref:[t,m],stateAttributesMapping:bp,props:[{role:`presentation`,hidden:!p,style:{pointerEvents:l?void 0:`none`},children:a},o]})}),Up=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=sp(),c=_f(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),Jc(`h2`,e,{ref:t,props:[{id:c},o]})});function Wp(e){let t=y.useRef(``),n=y.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:y.useCallback(n=>{n.detail===0?e(n,`keyboard`):(`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``)},[e]),onPointerDown:n}}function Gp(e,t){let n=y.useRef(e),r=$(t);X(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function Kp(e,t){let{onClick:n,onPointerDown:r}=Wp($((n,r)=>{(typeof e==`function`?e():e)||t(r||(Ki?`touch`:``))}));return y.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function qp(e){let[t,n]=y.useState(null),r=Kp(e,n);return Gp(e,t=>{t&&!e&&n(null)}),y.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}let Jp=Oi(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,payload:c,handle:l,...u}=e,d=sp(!0),f=Lu(l)??d;if(!f)throw Error(Pi(79));let p=_f(s),m=f.useState(`floatingRootContext`),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`triggerPopupId`,p),_=y.useRef(null),{registerTrigger:v,isMountedByThisTrigger:b}=lu(p,_,f,{payload:c}),{getButtonProps:x,buttonRef:S}=pp({disabled:a,native:o}),C=kl(m),w=Kp(()=>f.select(`open`),e=>{f.set(`openMethod`,e)}),T={disabled:a,open:h},E=f.useState(`triggerProps`,b);return Jc(`button`,e,{state:T,ref:[S,t,v,_],props:[C.reference,E,w,{[nl]:``,id:p,"aria-haspopup":`dialog`,"aria-expanded":h,"aria-controls":g},u,x],stateAttributesMapping:qa})});Ze(),ti(Xe);function Yp(){return/* @__PURE__ */ (0,A.jsx)(Y,{name:`circle-notch`,className:`ui-spin`,size:16})}function Xp(e){let{variant:t=`secondary`,loading:n,icon:r,className:i,children:a,disabled:o,onClick:s,...c}=e,{confirm:l,confirmed:u,...d}=c,[f,p]=y.useState(!1);G(t===`danger`&&!l&&!u,`Button`,`a danger button needs confirm={{ title }} (or confirmed when it is the button inside the confirm Dialog).`);let m=y.useRef(null),h=/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,...d,className:M(`ui-btn`,`ui-btn-`+t,n&&`is-loading`,i),disabled:o||n,"aria-busy":n||void 0,onClick:e=>{l?(e.preventDefault(),m.current={event:e,button:e.currentTarget},p(!0)):s?.(e)},children:[n?/* @__PURE__ */ (0,A.jsx)(Yp,{}):r?/* @__PURE__ */ (0,A.jsx)(fi,{icon:r}):null,a]});return l?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[h,/* @__PURE__ */ (0,A.jsx)(Zp,{open:f,onClose:()=>p(!1),title:l.title,tone:`danger`,confirmLabel:l.confirmLabel??(typeof a==`string`?a:w(`刪除`)),onConfirm:()=>{p(!1);let e=m.current;e&&(s?.(e.event),e.button.type===`submit`&&e.button.form?.requestSubmit(e.button))},children:l.body})]}):h}ir(),ti(rr);function Zp(e){let{open:t,onClose:n,title:r,children:i,confirmLabel:a,onConfirm:o,cancelLabel:s,tone:c=`default`,confirmLoading:l,actions:u,className:d}=e;G(a!==void 0!=!!o,`Dialog`,`confirmLabel and onConfirm go together; pass both, or pass actions.`),G(t===void 0&&e.modal!==!1,`Dialog`,`pass open={…} (and onClose) to show a dialog; rendering it conditionally without open draws a static panel with no focus trap or Esc. Use modal={false} for a static preview.`),G(t!==void 0&&!n,`Dialog`,`an open dialog needs onClose, or Esc and the backdrop cannot close it.`);let f=u??(a&&o?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(Xp,{onClick:n,children:s??w(`取消`)}),c===`danger`?/* @__PURE__ */ (0,A.jsx)(Xp,{variant:`danger`,confirmed:!0,loading:l,onClick:o,children:a}):/* @__PURE__ */ (0,A.jsx)(Xp,{variant:`primary`,loading:l,onClick:o,children:a})]}):null),p=y.useId(),m=t===void 0,h=/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`}),g=/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dialog-head`,children:[m?/* @__PURE__ */ (0,A.jsx)(`div`,{id:p,className:`ui-dialog-title`,children:r}):/* @__PURE__ */ (0,A.jsx)(Up,{className:`ui-dialog-title`,children:r}),n&&m?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-dialog-close`,"aria-label":w(`關閉`),onClick:n,children:h}):n?/* @__PURE__ */ (0,A.jsx)(gp,{className:`ui-dialog-close`,"aria-label":w(`關閉`),children:h}):null]}),_=/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[g,i?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dialog-body`,children:i}):null,f?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dialog-actions`,children:f}):null]});return m?/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-dialog`,d),role:`dialog`,"aria-labelledby":p,children:_}):/* @__PURE__ */ (0,A.jsx)(Vp,{open:t,onOpenChange:e=>!e&&n?.(),children:/* @__PURE__ */ (0,A.jsxs)(Cp,{children:[/* @__PURE__ */ (0,A.jsx)(cp,{className:`ui-backdrop`}),/* @__PURE__ */ (0,A.jsx)(Hp,{className:`ui-dialog-viewport`,children:/* @__PURE__ */ (0,A.jsx)(xp,{className:M(`ui-dialog`,d),children:_})})]})})}ir(),ti(rr);function Qp({open:e,onClose:t,title:n,actions:r,dirty:i,width:a,side:o=`right`,confirmTitle:s,confirmText:c,children:l}){let[u,d]=y.useState(!1),f=()=>i?d(!0):t(),p=y.useRef(null);return/* @__PURE__ */ (0,A.jsx)(Vp,{open:e,onOpenChange:e=>!e&&f(),children:/* @__PURE__ */ (0,A.jsxs)(Cp,{children:[/* @__PURE__ */ (0,A.jsx)(cp,{className:`ui-drawer-backdrop`}),/* @__PURE__ */ (0,A.jsxs)(xp,{ref:p,initialFocus:()=>p.current?.querySelector(`.ui-drawer-body :is(input, textarea, select, button, [tabindex]):not([disabled], [tabindex="-1"]), .ui-drawer-foot button:not([disabled])`)??!0,className:o===`left`?`ui-drawer is-left`:`ui-drawer`,style:a?{width:a}:void 0,children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-drawer-head`,children:[/* @__PURE__ */ (0,A.jsx)(Up,{className:`ui-drawer-title`,children:n}),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-drawer-close ui-dialog-close`,"aria-label":w(`關閉`),onClick:f,children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`})})]}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-drawer-body`,children:l}),r?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-drawer-foot`,children:typeof r==`function`?r(f):r}):null,/* @__PURE__ */ (0,A.jsx)(Zp,{open:u,onClose:()=>d(!1),title:s||w(`放棄未儲存的變更?`),tone:`danger`,cancelLabel:w(`繼續編輯`),confirmLabel:w(`放棄`),onConfirm:()=>{d(!1),t()},children:c||w(`關閉後,剛才的修改不會保留。`)})]})]})})}let $p=`pointer`;typeof document<`u`&&(document.addEventListener(`keydown`,()=>$p=`key`,!0),document.addEventListener(`pointerdown`,()=>$p=`pointer`,!0));function em(){if(typeof document>`u`)return;let e=document.querySelector(`main`),t=e?.querySelector(`h1, h2`)??document.querySelector(`.ui-topbar-title`)??e;t&&(t.tabIndex<0&&!t.hasAttribute(`tabindex`)&&t.setAttribute(`tabindex`,`-1`),t.setAttribute(`data-ui-main-focus`,$p),t.focus({preventScroll:!1}))}lt(),ti(ct);let tm=`ui-nav-collapsed`,nm=`ui-nav-pinned`,rm=`\0more`;function im({nav:e,value:t,onNavigate:n,brand:r,title:i,breadcrumb:a,onSearch:o,actions:s,children:c,tabLabels:l,defaultPinned:u=!1,className:d}){let f=ee(),p=H(`(min-width: 600px) and (max-width: 1024px)`),[m,h]=y.useState(()=>I(tm)===`1`),[g,_]=y.useState(()=>{let e=I(nm);return e==null?I(tm)!=null||u:e===`1`}),[v,b]=y.useState(!1),x=y.useRef(void 0),S=y.useRef(void 0),C=e=>{clearTimeout(x.current),clearTimeout(S.current),e?x.current=setTimeout(()=>b(!0),100):S.current=setTimeout(()=>b(!1),300)};y.useEffect(()=>()=>{clearTimeout(x.current),clearTimeout(S.current)},[]);let T=g?m:!v,E=()=>{I(nm,g?`0`:`1`),_(!g),b(!1)},D=e.flatMap(e=>e.items),O=e=>D.find(t=>t.children?.some(t=>t.id===e)),k=D.filter(e=>!!e.icon),j=D.some(e=>!e.icon||(e.children?.length??0)>1)||k.length>5,N=k.slice(0,j?4:5).map(e=>({id:e.id,label:e.label,icon:e.icon}));j&&N.push({id:rm,label:w(`更多`),icon:`dots-three`});let[P,F]=y.useState(!1);P&&!f&&!p&&F(!1),G(f&&k.length<2,`AppShell`,`phones show the top-level nav items as bottom tabs; give at least 2 of them an icon.`);let L=O(t)?.id??t,R=N.some(e=>e.id===L)?L:rm,z=e=>{if(e===rm)return F(!0);e!==L&&n(D.find(t=>t.id===e)?.children?.[0]?.id??e)},B=y.useRef(null),[V,U]=y.useState(!1);return y.useEffect(()=>{let e=B.current;if(!e)return;let t=e.scrollTop,n=()=>{let n=e.scrollTop;Math.abs(n-t)<8||(U(n>t&&n>64),t=n)};return e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},[]),y.useEffect(()=>{yi()},[]),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-shell`,f&&`is-phone`,d),children:[/* @__PURE__ */ (0,A.jsx)(`a`,{className:`ui-skip`,href:`#main`,onClick:e=>{e.preventDefault(),em()},children:w(`跳到主要內容`)}),f||p?null:g?/* @__PURE__ */ (0,A.jsx)(ep,{sections:e,value:t,onChange:n,brand:r,collapsed:T,pinned:!0,onPin:E,onToggle:()=>{I(tm,m?`0`:`1`),h(!m)}}):/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-shell-rail`,v&&`is-open`),onPointerEnter:e=>e.pointerType===`mouse`&&C(!0),onPointerLeave:e=>e.pointerType===`mouse`&&C(!1),onFocus:e=>{e.target.matches(`:focus-visible`)&&(clearTimeout(S.current),b(!0))},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||b(!1)},onKeyDown:e=>{e.key===`Escape`&&v&&(e.stopPropagation(),b(!1))},children:/* @__PURE__ */ (0,A.jsx)(ep,{sections:e,value:t,onChange:e=>{clearTimeout(x.current),b(!1),n(e)},brand:r,collapsed:T,onPin:E})}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-shell-body`,children:[/* @__PURE__ */ (0,A.jsx)(ip,{className:M(`ui-shell-top`,V&&`is-hidden`),title:i,breadcrumb:a,onSearch:o??!1,onMenu:p?()=>F(!0):void 0,children:s}),/* @__PURE__ */ (0,A.jsx)(`main`,{ref:B,className:`ui-shell-main`,tabIndex:-1,children:c}),f&&N.length?/* @__PURE__ */ (0,A.jsx)(ap,{items:N,value:R,onChange:z,labels:l}):null,f||p?/* @__PURE__ */ (0,A.jsx)(Qp,{open:P,onClose:()=>F(!1),title:w(`全部頁面`),side:p?`left`:`right`,width:p?300:void 0,children:/* @__PURE__ */ (0,A.jsx)(ep,{className:`ui-shell-allnav`,sections:e,value:t,onChange:e=>{F(!1),n(e)}})}):null]})]})}function am({columns:e=3,children:t,className:n}){return/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-grid`,`is-`+e,n),children:t})}function om({children:e,className:t}){return/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-page`,t),children:e})}let sm=`ui-theme`,cm=`ui-accent`,lm=e=>e===`auto`||e===`light`||e===`dark`;function um(){let e=I(sm);return lm(e)?e:`auto`}function dm(e){return e===`auto`?typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:e}let fm;function pm(e){let t=document.documentElement;L()||(t.classList.add(`ui-theme-fade`),clearTimeout(fm),fm=setTimeout(()=>t.classList.remove(`ui-theme-fade`),320)),t.setAttribute(`data-theme`,dm(e)),t.setAttribute(`data-theme-setting`,e),I(sm,e),Em(hm(),!0)}let mm={"#8a4fd6":`#864ad1`,"#c2407a":`#ba3873`,"#cd3a2f":`#c53228`,"#b85a0e":`#ab5101`,"#1a844a":`#077b42`,"#0e827d":`#027874`};function hm(){let e=I(cm);if(!e)return`#2457d6`;let t=mm[e.toLowerCase()];return t&&I(cm,t),t??e}let gm=e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16));function _m(e){let t=e.trim().toLowerCase(),n=/^#([0-9a-f])([0-9a-f])([0-9a-f])[0-9a-f]?$/.exec(t);if(n)return`#`+n[1]+n[1]+n[2]+n[2]+n[3]+n[3];let r=/^#([0-9a-f]{6})(?:[0-9a-f]{2})?$/.exec(t);if(r)return`#`+r[1];let i=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*[\d.]+%?)?\s*\)$/.exec(t);if(i){let e=i.slice(1,4).map(Number);if(e.every(e=>e>=0&&e<=255))return`#`+e.map(e=>Math.round(e).toString(16).padStart(2,`0`)).join(``)}return null}function vm(e,t,n){let r=gm(e),i=gm(t);return`#`+r.map((e,t)=>Math.round(e+(i[t]-e)*n).toString(16).padStart(2,`0`)).join(``)}function ym(e){let t=[.2126,.7152,.0722];return gm(e).map(e=>(e/=255,e<=.03928?e/12.92:((e+.055)/1.055)**2.4)).reduce((e,n,r)=>e+n*t[r],0)}function bm(e,t){let n=ym(e),r=ym(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function xm(e,t,n,r,...i){let a=[n,r,...i].map(_m);if(a.some(e=>!e))return e;let o=e=>a.every(t=>bm(e,t)>=4.5),s=t?`#ffffff`:`#000000`,c=t?.05:.04,l=e;for(let t=1;t*c<=1&&!o(l);t++)l=vm(e,s,t*c);return l}let Sm=`#171512`;function Cm(e){return bm(`#ffffff`,e)>=bm(Sm,e)?`#ffffff`:Sm}function wm(e,t,n,r,...i){let a=[n,r,...i].map(_m);if(a.some(e=>!e))return e;let o=e=>a.every(t=>bm(e,t)>=3)&&bm(Cm(e),e)>=4.5,s=t?`#ffffff`:`#000000`,c=t?.05:.04,l=e;for(let t=1;t*c<=1&&!o(l);t++)l=vm(e,s,t*c);return l}let Tm=[[`藍`,`#2457d6`],[`靛`,`#5b4fd6`],[`紫`,`#864ad1`],[`桃紅`,`#ba3873`],[`紅`,`#c53228`],[`橘`,`#ab5101`],[`綠`,`#077b42`],[`青`,`#027874`]];function Em(e,t=!1){if(!/^#[0-9a-fA-F]{6}$/.test(e))return!1;e=e.toLowerCase();let n=document.documentElement,r=n.getAttribute(`data-theme`)===`dark`,i=getComputedStyle(n),a=_m(i.getPropertyValue(`--surface`))??(r?`#393530`:`#ffffff`),o=_m(i.getPropertyValue(`--bg`))??(r?`#2f2a25`:`#fcfbfb`),s=_m(i.getPropertyValue(`--surface-sub`))??(r?`#443f3b`:`#f6f5f4`),c=_m(i.getPropertyValue(`--surface-chrome`))??(r?`#3d3834`:`#ffffff`),l=r?vm(a,e,.22):vm(`#ffffff`,e,.12),u=xm(e,r,o,a,s,c,l),d=wm(e,r,o,a,s,c,l),f=r?`#ffffff`:`#000000`,p={"--accent":d,"--accent-hover":vm(d,f,.12),"--accent-press":vm(d,f,.22),"--accent-soft":l,"--accent-text":u,"--on-accent":Cm(d),"--focus":u,"--focus-ring":u};for(let[e,t]of Object.entries(p))n.style.setProperty(e,t);return t||I(cm,e),!0}let Dm=!1;function Om(){pm(um()),yi(),Dm||typeof window.matchMedia!=`function`||(Dm=!0,window.matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,()=>{um()===`auto`&&pm(`auto`)}))}function km(e,t){let n=e.trim();/^[a-z][a-z0-9-]*$/.test(n)&&typeof document<`u`&&(n=getComputedStyle(t??document.documentElement).getPropertyValue(`--`+n));let r=_m(n);return r?bm(r,`#171512`)>=bm(r,`#ffffff`)?`#171512`:`#ffffff`:`#171512`}function Am(e,t,n){let r=n>t?(e-t)/(n-t):0;return`heat-${Math.min(7,Math.max(1,Math.round(r*6)+1))}`}function jm(e,t){let n=Math.abs(e);if(n<=t.zero)return`diverge-zero`;let r=n>=t.strong;return e<0?r?`diverge-neg-strong`:`diverge-neg`:r?`diverge-pos-strong`:`diverge-pos`}qe(),ti(Ke);let Mm=Tm,Nm=/^#[0-9a-fA-F]{6}$/;function Pm({value:e,onChange:t,label:n,className:r}){let[i,a]=y.useState(()=>(e||hm()).toLowerCase()),[o,s]=y.useState(``),c=(e||i).toLowerCase(),l=e=>{a(e),t?t(e):Em(e)},u=!!o&&!Nm.test(o),d=y.useRef([]),f=Math.max(0,Mm.findIndex(([,e])=>e===c));return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-accentpick`,r),children:[/* @__PURE__ */ (0,A.jsx)(`div`,{role:`radiogroup`,"aria-label":n||w(`強調色`),className:`ui-accentpick-swatches`,children:Mm.map(([e,t],n)=>{let r=c===t;return/* @__PURE__ */ (0,A.jsx)(`button`,{ref:e=>{d.current[n]=e},type:`button`,role:`radio`,"aria-checked":r,tabIndex:n===f?0:-1,"aria-label":w(e),title:w(e),className:M(`ui-swatch`,r&&`is-on`),style:{background:t,color:t},onClick:()=>{s(``),l(t)},onKeyDown:e=>{if(W(e))return;let t=Mm.length,r=e.key===`ArrowRight`||e.key===`ArrowDown`?(n+1)%t:e.key===`ArrowLeft`||e.key===`ArrowUp`?(n-1+t)%t:-1;r<0||(e.preventDefault(),d.current[r]?.focus(),s(``),l(Mm[r][1]))},children:r?/* @__PURE__ */ (0,A.jsx)(Y,{name:`check`,size:14}):null},t)})}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-accentpick-hex`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-accentpick-preview`,style:{background:!u&&o?o:c}}),/* @__PURE__ */ (0,A.jsx)(`input`,{className:M(`ui-input`,u&&`is-invalid`),"aria-label":w(`自訂強調色(色碼)`),"aria-invalid":u||void 0,value:o,placeholder:c,onChange:e=>{let t=e.target.value.trim();s(t),Nm.test(t)&&l(t.toLowerCase())}}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-field-hint`,u&&`is-error`),children:w(u?`色碼格式不正確,例如 #2457d6`:`輸入 # 加 6 碼`)})]})]})}let Fm=()=>!document.activeElement||document.activeElement===document.body;function Im(e){let t=y.useRef(null),n=y.useRef(!1);y.useEffect(()=>{if(e&&!n.current){let e=document.activeElement;t.current=e instanceof HTMLElement&&e!==document.body?e:null}if(!e&&n.current){let r=t.current;t.current=null;let i=document.activeElement,a=performance.now()+2e3,o=0,s=()=>{if(Fm()){r?.isConnected?r.focus():em();return}let e=document.activeElement;!(e===i||e?.closest(`[data-ending-style]`))||performance.now()>a||(o=requestAnimationFrame(s))};return o=requestAnimationFrame(s),n.current=e,()=>cancelAnimationFrame(o)}n.current=e},[e])}function Lm(e,t){let n=y.useRef(t);y.useEffect(()=>{n.current=t}),y.useEffect(()=>{let t=e.current;if(!t)return;let r=null,i=-1,a=()=>Array.from(t.querySelectorAll(`button:not([disabled]), a[href], [tabindex]:not([tabindex="-1"]), input:not([disabled]), [role="tab"]`)).filter(e=>e.getClientRects().length>0&&!e.matches(`:disabled`)),o=e=>{e.target instanceof HTMLElement&&(r=e.target,i=a().indexOf(r))},s=()=>{let e=a(),t=n.current?.()??e[Math.min(i,e.length-1)]??null;r=null,t?t.focus():em()},c=0,l=new MutationObserver(()=>{if(!r||r.isConnected&&!r.matches(`:disabled`))return;if(Fm())return s();let e=r;cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=requestAnimationFrame(()=>{r===e&&(Fm()||document.activeElement===e)&&s()})})});return t.addEventListener(`focusin`,o),l.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`disabled`]}),()=>{t.removeEventListener(`focusin`,o),l.disconnect(),cancelAnimationFrame(c)}},[e])}let Rm=/*#__PURE__*/ y.createContext(void 0);function zm(e){let t=y.useContext(Rm);if(t===void 0&&!e)throw Error(Pi(33));return t}let Bm=/*#__PURE__*/ y.createContext(void 0);function Vm(e){let t=y.useContext(Bm);if(t===void 0&&!e)throw Error(Pi(36));return t}let Hm=/*#__PURE__*/ y.createContext(void 0);function Um(e=!0){let t=y.useContext(Hm);if(t===void 0&&!e)throw Error(Pi(25));return t}function Wm({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=y.useRef(e!==void 0),[a,o]=y.useState(()=>t);return[i&&e!==void 0?e:a,y.useCallback(e=>{i||o(e)},[])]}let Gm=/*#__PURE__*/ y.createContext(null);function Km(e=`root`){let t=y.useContext(Gm),n=y.useContext(Bm);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}let qm={visible:!0,ref:null};function Jm(){return qm}function Ym(e,t,n=`root`){let r=Km(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??Jm)({label:e.label,children:e.children,render:e.render}),a=Fo(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}let Xm=/*#__PURE__*/ y.createContext(void 0);function Zm(e){e.preventDefault()}function Qm(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=Vm(),u=Um(!0),d=c.type===`submenu-trigger`,f=d?l.parentVirtualFocus:l.virtualFocus,p=(d&&l.parent.type===`menu`?l.parent.store:l.store).useState(`webkitAriaSelected`,n),{events:m}=a.useState(`floatingTreeRoot`),h=a.useState(`open`),g=u!==void 0,_=!f&&h&&n?0:-1;return y.useMemo(()=>({id:r,role:`menuitem`,tabIndex:_,"aria-selected":p,onMouseDown:f?Zm:void 0,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&m.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&m.emit(`close`,{domEvent:e.nativeEvent,reason:_o})},onMouseUp(e){if(u){let t=u.initialCursorPointRef.current;if(u.initialCursorPointRef.current=null,g&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||g&&!Yi&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&fp(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}let $m={type:`regular-item`};function eh(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=y.useRef(null),{getButtonProps:d,buttonRef:f}=pp({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=Qm({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=y.useCallback(e=>Fc(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=Fo(u,f);return y.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}let th=/*#__PURE__*/ y.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function nh(){return y.useContext(th)}function rh(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=nh(),u=y.useRef(-1),[d,f]=y.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=y.useRef(null),h=y.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return X(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}let ih={checked(e){return e?{"data-checked":``}:{"data-unchecked":``}},...Ba},ah=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!1,checked:l=!1,onCheckedChange:u,style:d,...f}=e,{store:p}=Vm(),m=rh({guess:!0,label:a}),h=_f(i),g=p.useState(`disabled`),_=p.useState(`isActive`,m.index),v=p.useState(`floatingNodeId`),b=p.useState(`itemProps`),x=s||g,{getItemProps:S,itemRef:C}=eh({closeOnClick:c,disabled:x,highlighted:_,id:h,store:p,nativeButton:o,nodeId:v,itemMetadata:$m}),w=y.useMemo(()=>({disabled:x,highlighted:_,checked:l}),[x,_,l]);function T(e){let t=Q(_o,e.nativeEvent,void 0,{preventUnmountOnClose:Ai});u?.(!l,t)}let E=Jc(`div`,e,{state:w,stateAttributesMapping:ih,props:[b,{role:`menuitemcheckbox`,"aria-checked":l,onClick:T},f,S],ref:[C,t,m.ref]});return/*#__PURE__*/ (0,A.jsx)(Xm.Provider,{value:w,children:E})}),oh=/*#__PURE__*/ y.forwardRef(function(e,t){let{checked:n,defaultChecked:r,onCheckedChange:i,...a}=e,[o,s]=Wm({controlled:n,default:r??!1,name:`MenuCheckboxItem`,state:`checked`}),c=Ym(e,t);function l(e,t){i?.(e,t),t.isCanceled||s(e)}return c.visible?/*#__PURE__*/ (0,A.jsx)(ah,{...a,checked:o,onCheckedChange:l,ref:c.ref}):null}),sh=/*#__PURE__*/ y.createContext(void 0);function ch(){let e=y.useContext(sh);if(e===void 0)throw Error(Pi(31));return e}let lh=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=y.useState(void 0),c=Jc(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return/*#__PURE__*/ (0,A.jsx)(sh.Provider,{value:s,children:c})}),uh=/*#__PURE__*/ y.forwardRef(function(e,t){let n=Km()?.Group??lh;return/*#__PURE__*/ (0,A.jsx)(n,{...e,ref:t})}),dh=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=_f(a),c=ch();return X(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),Jc(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),fh=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,{store:d}=Vm(),f=rh({guess:!0,label:a}),p=_f(i),m=d.useState(`disabled`),h=d.useState(`isActive`,f.index),g=d.useState(`floatingNodeId`),_=d.useState(`itemProps`),v=s||m,{getItemProps:y,itemRef:b}=eh({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:$m});return Jc(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),ph=/*#__PURE__*/ y.forwardRef(function(e,t){let n=Ym(e,t);return n.visible?/*#__PURE__*/ (0,A.jsx)(fh,{...e,ref:n.ref}):null}),mh=/*#__PURE__*/ y.createContext(void 0);function hh(e){let t=y.useContext(mh);if(t===void 0&&!e)throw Error(Pi(69));return t}let gh=/*#__PURE__*/ y.createContext(void 0);function _h(){return y.useContext(gh)}function vh(e,t){let n=Qc(e.render);if(/*#__PURE__*/ y.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function yh(e,t,n){let r=vh(e,t),i=r===t?void 0:r;return[r,y.useCallback(e=>n?.(e?i:void 0),[i,n])]}function bh(e,t,n){let r=Qc(e.render),i=/*#__PURE__*/ y.isValidElement(r)?r.props:void 0,a=e[`aria-label`]??i?.[`aria-label`],o=e[`aria-labelledby`]??i?.[`aria-labelledby`];return o==null&&!a&&(o=t?t.id||void 0:n||void 0),o}let xh=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,id:o,initialFocus:s,...c}=e,{store:l,defaultFloatingId:u,setRenderedFloatingId:d,virtualFocus:f,orientation:p}=Vm(),m=_h(),{side:h,align:g}=zm(),_=hh(!0)!=null,v=l.useState(`open`),b=l.useState(`transitionStatus`),x=l.useState(`popupProps`),S=l.useState(`mounted`),C=l.useState(`instantType`),w=l.useState(`activeTriggerElement`),T=l.useState(`parent`),E=l.useState(`lastOpenChangeReason`),D=l.useState(`rootId`),O=l.useState(`floatingRootContext`),k=l.useState(`floatingTreeRoot`),j=l.useState(`closeDelay`),M=l.useState(`hoverEnabled`),N=l.useState(`disabled`),P=l.useState(`openMethod`),F=l.useState(`activeTriggerId`),I=l.useState(`listElement`),[L,R]=yh(e,u,d),z=bh(e,w,F),B=T.type===`menu`?m:void 0,V=T.type===`context-menu`,H=s??T.type!==`menu`;s===void 0&&I&&T.type!==`menu`&&(H=()=>l.state.activeIndex===null&&I),Ql({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),y.useEffect(()=>{function e(e){l.setOpen(!1,Q(e.reason,e.domEvent))}return k.events.on(`close`,e),()=>{k.events.off(`close`,e)}},[k.events,l]),Ku(O,{enabled:M&&!N&&!V&&T.type!==`menubar`,closeDelay:j});let U=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:ee,handleFocus:te}=(y.useContext(Gm)?.useParentHandoff??Ch)(l,T,v,f),ne=Jc(`div`,e,{state:{transitionStatus:b,side:h,align:g,open:v,nested:T.type===`menu`,instant:C},ref:[t,l.context.popupRef,U,R],stateAttributesMapping:Xa,props:[x,{id:L,...I?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":z},onKeyDown(e){B?.onPopupKeyDown?.(e),_&&yp.has(e.key)&&e.stopPropagation()},onFocus:te},Uf(b),c,{"data-rootownerid":D}]}),W=T.type===void 0||V;(w||T.type===`menubar`&&E!==`outside-press`)&&(W=!0);let re=B?.getReturnElement??ee;return/*#__PURE__*/ (0,A.jsx)(Ol,{context:O,openInteractionType:P,modal:V,disabled:!S,returnFocus:a??re??W,explicitReturnFocus:a===void 0&&re?!1:void 0,initialFocus:H,restoreFocus:!0,getInsideElements:T.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:T.type===`menubar`?void 0:k,previousFocusableElement:w,nextFocusableElement:T.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:ne})}),Sh={parentVirtualFocusRef:void 0,handleFocus:void 0};function Ch(){return Sh}let wh=/*#__PURE__*/ y.forwardRef(function(e,t){let n=Km()?.Popup??xh;return/*#__PURE__*/ (0,A.jsx)(n,{...e,ref:t})}),Th=/*#__PURE__*/ y.createContext(void 0);function Eh(){let e=y.useContext(Th);if(e===void 0)throw Error(Pi(32));return e}let Dh=/*#__PURE__*/ y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=Vm();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return/*#__PURE__*/ (0,A.jsx)(Th.Provider,{value:n,children:/*#__PURE__*/ (0,A.jsx)(ul,{ref:t,...r,portalOwnerRole:o})})});function Oh(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=$(i),[,o]=y.useState(0),s=Si(Ah).current,c=Si(kh).current,l=y.useRef(0),u=y.useRef(!0),d=y.useRef(null),f=y.useRef(null),p=$(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=$((e,t)=>{c.set(e,t),p()}),h=$(e=>{c.delete(e),p()}),g=$(e=>{let t=/* @__PURE__ */ new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!Nh(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&Ph(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=/* @__PURE__ */ new Set;for(let t=1;t<e.length;t+=1){let r=Mh(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=$(()=>{let[e,t]=jh(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});X(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),X(()=>{u.current&&v()}),X(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let b=$(e=>(s.add(e),()=>{s.delete(e)})),x=y.useMemo(()=>({register:m,unregister:h,subscribeMapChange:b,nextIndexRef:l}),[m,h,b,l]);return/*#__PURE__*/ (0,A.jsx)(th.Provider,{value:x,children:t})}function kh(){return/* @__PURE__ */ new Map}function Ah(){return/* @__PURE__ */ new Set}function jh(e){let t=/* @__PURE__ */ new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>Ph(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function Mh(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function Nh(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function Ph(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function Fh(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=y.useRef(null),o=y.useRef(null),s=Zl(r);X(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),X(()=>{let e=n,r=a.current;if(e&&(a.current=e),!r||!e||e===r||!t.select(`open`))return;t.set(`instantType`,void 0);let i=new AbortController;return o.current=i,s(()=>{t.select(`open`)&&t.set(`instantType`,`trigger-change`)},i.signal),()=>{i.abort()}},[n,s,t])}function Ih(e,t,n,r){let[i,a]=y.useState(!1);X(()=>{if(!e||!t||n==null){a(!1);return}let r=Zo(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-20)},[e,t,n]),Pp(e&&(!t||i),r)}let Lh=/*#__PURE__*/ y.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=rl,style:g,..._}=e,{store:v,virtualFocus:b,syncHighlightedItem:x}=Vm(),S=Eh(),C=Um(!0),w=v.useState(`parent`),T=v.useState(`floatingRootContext`),E=v.useState(`floatingTreeRoot`),D=v.useState(`mounted`),O=v.useState(`open`),k=v.useState(`modal`),j=v.useState(`openMethod`),M=v.useState(`activeTriggerElement`),N=v.useState(`transitionStatus`),P=v.useState(`positionerElement`),F=v.useState(`instantType`),I=v.useState(`adaptiveOrigin`),L=v.useState(`lastOpenChangeReason`),R=v.useState(`floatingNodeId`),z=v.useState(`floatingParentNodeId`),B=T.useState(`domReferenceElement`),V=n,H=c,U=l,ee=s,te=h;w.type===`context-menu`&&(V=n??w.context?.anchor,ee??=`start`,!o&&ee!==`center`&&(U=e.alignOffset??2,H=e.sideOffset??-5));let ne=o,W=ee;w.type===`menu`?(ne??=`inline-end`,W??=`start`,te=e.collisionAvoidance??il):w.type===`menubar`&&(ne??=w.context.orientation===`vertical`?`inline-end`:`bottom`,W??=`start`);let re=w.type===`context-menu`,ie=Bf({anchor:V,floatingRootContext:T,positionMethod:C?`fixed`:r,mounted:D,side:ne,sideOffset:H,align:W,alignOffset:U,arrowPadding:re?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:R,keepMounted:S,disableAnchorTracking:m,collisionAvoidance:te,shift:re?{crossAxis:!(`side`in te&&te.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:E,adaptiveOrigin:I,lazyFlip:b?`placement`:!1});y.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===R&&v.set(`hoverEnabled`,!1),e.nodeId!==R&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,Q(Oo)))}return E.events.on(`menuopenchange`,e),()=>{E.events.off(`menuopenchange`,e)}},[v,E.events,R]),y.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,Q(t))}return E.events.on(`menuopenchange`,e),()=>{E.events.off(`menuopenchange`,e)}},[E.events,v]);let G=zi();y.useEffect(()=>{O||G.clear()},[O,G]),y.useEffect(()=>{function e(e){if(O&&e.nodeId===v.select(`floatingParentNodeId`)){if(e.target&&M&&M!==e.target){let e=v.select(`closeDelay`);e>0?G.isStarted()||G.start(e,()=>{v.setOpen(!1,Q(Oo))}):v.setOpen(!1,Q(Oo))}else G.clear()}}return E.events.on(`itemhover`,e),()=>{E.events.off(`itemhover`,e)}},[E.events,O,M,v,G]),y.useEffect(()=>{let e={open:O,nodeId:R,parentNodeId:z,reason:v.select(`lastOpenChangeReason`)};E.events.emit(`menuopenchange`,e)},[E.events,O,v,R,z]),Fh({store:v,domReference:B,positionerElement:P,open:O});let K={open:O,side:ie.side,align:ie.align,anchorHidden:ie.anchorHidden,nested:w.type===`menu`,instant:F},q=w.type===`menubar`&&w.context.modal;Ih(O&&(q||k&&L!==`trigger-hover`),j===`touch`,P,M);let ae=Wf(e,K,{styles:ie.positionerStyles,transitionStatus:N,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!D,inert:!O}),oe=D&&w.type!==`menu`&&(w.type!==`menubar`&&k&&L!==`trigger-hover`||w.type===`menubar`&&w.context.modal),se=null;return w.type===`menubar`?se=w.context.contentElement:w.type===void 0&&(se=M),/*#__PURE__*/ (0,A.jsxs)(Rm.Provider,{value:ie,children:[oe&&/*#__PURE__*/ (0,A.jsx)(Sp,{ref:w.type===`context-menu`||w.type===`nested-context-menu`?w.context.internalBackdropRef:null,inert:Jf(!O),cutout:se}),/*#__PURE__*/ (0,A.jsx)(vl,{id:R,children:/*#__PURE__*/ (0,A.jsx)(Oh,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:x,children:ae})})]})}),Rh=/*#__PURE__*/ y.createContext(void 0);function zh(){let e=y.useContext(Rh);if(e===void 0)throw Error(Pi(34));return e}let Bh=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,value:i,defaultValue:a,onValueChange:o,disabled:s=!1,style:c,"aria-labelledby":l,...u}=e,[d,f]=y.useState(void 0),[p,m]=Wm({controlled:i,default:a,name:`MenuRadioGroup`}),h=$((e,t)=>{o?.(e,t),t.isCanceled||m(e)}),g=Jc(`div`,e,{state:{disabled:s},ref:t,props:{role:`group`,"aria-labelledby":l??d,"aria-disabled":s||void 0,...u}}),_=y.useMemo(()=>({value:p,setValue:h,disabled:s}),[p,h,s]);return/*#__PURE__*/ (0,A.jsx)(sh.Provider,{value:f,children:/*#__PURE__*/ (0,A.jsx)(Rh.Provider,{value:_,children:g})})}),Vh=/*#__PURE__*/ y.memo(/*#__PURE__*/ y.forwardRef(function(e,t){let n=Km()?.RadioGroup??Bh;return/*#__PURE__*/ (0,A.jsx)(n,{...e,ref:t})})),Hh=/*#__PURE__*/ y.createContext(void 0);function Uh(){let e=y.useContext(Hh);if(e===void 0)throw Error(Pi(35));return e}let Wh=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!1,value:l,style:u,...d}=e,{store:f}=Vm(),{value:p,setValue:m,disabled:h}=zh(),g=rh({guess:!0,label:a}),_=_f(i),v=f.useState(`isActive`,g.index),b=f.useState(`floatingNodeId`),x=f.useState(`itemProps`),S=f.useState(`disabled`),C=s||h||S,w=p===l,{getItemProps:T,itemRef:E}=eh({closeOnClick:c,disabled:C,highlighted:v,id:_,store:f,nativeButton:o,nodeId:b,itemMetadata:$m}),D=y.useMemo(()=>({disabled:C,highlighted:v,checked:w}),[C,v,w]);function O(e){let t=Q(_o,e.nativeEvent,void 0,{preventUnmountOnClose:Ai});m(l,t)}let k=Jc(`div`,e,{state:D,stateAttributesMapping:ih,props:[x,{role:`menuitemradio`,"aria-checked":w,onClick:O},d,T],ref:[E,t,g.ref]});return/*#__PURE__*/ (0,A.jsx)(Hh.Provider,{value:D,children:k})}),Gh=/*#__PURE__*/ y.forwardRef(function(e,t){let n=Ym(e,t);return n.visible?/*#__PURE__*/ (0,A.jsx)(Wh,{...e,ref:n.ref}):null}),Kh=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=Uh(),c=y.useRef(null),{transitionStatus:l,mounted:u,setMounted:d}=ql(s.checked);return Ql({batch:!0,enabled:!s.checked,open:s.checked,ref:c,onComplete(){s.checked||d(!1)}}),Jc(`span`,e,{state:{checked:s.checked,disabled:s.disabled,highlighted:s.highlighted,transitionStatus:l},stateAttributesMapping:ih,ref:[t,c],props:{"aria-hidden":!0,...o},enabled:a||u})}),qh=/*#__PURE__*/ y.createContext(null);function Jh(e){let t=y.useContext(qh);if(t===null&&!e)throw Error(Pi(5));return t}function Yh(e){return e==null?po:e.type.startsWith(`key`)?To:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?Eo:po}let Xh={...Iu,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,keyboardOpen:e=>e.keyboardOpen,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,listElement:e=>e.listElement,triggerControlsId:(e,t)=>{let n=Iu.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>Zi&&e.inputFocused&&t?!0:void 0,highlightedItemId:e=>e.highlightedItem?.id||void 0,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType===`trigger-change`&&!Iu.open(e)?void 0:e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}};var Zh=class extends Du{constructor(e,t,n=!1){let r=new mu,i=$h(r,t,n,e);super(i,Qh(r),Xh),this.observe(`parent`,e=>{e.type===`menu`?this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef:e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef)})}subscribeToParentMenu(){let e=this.state.parent;if(e.type!==`menu`)return;let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);return e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}setActiveIndex(e,t,n){if(this.state.activeIndex!==e){let r=(e===null?void 0:this.context.itemDomElements.current[e])===this.context.reportedItem;this.context.highlightReason=r?`none`:t,this.context.highlightEvent=r?void 0:n}this.set(`activeIndex`,e)}highlightItem(e,t,n){let r=this.context.itemDomElements.current.indexOf(e);r>-1&&this.setActiveIndex(r,t,n)}};function Qh(e){return{positionerRef:/*#__PURE__*/ y.createRef(),popupRef:/*#__PURE__*/ y.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:/*#__PURE__*/ y.createRef(),beforeTriggerFocusGuardRef:/*#__PURE__*/ y.createRef(),beforeContentFocusGuardRef:/*#__PURE__*/ y.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function $h(e,t,n=!1,r){return{...Au(e,t,n),disabled:!1,modal:!0,openMethod:null,keyboardOpen:!1,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,listElement:null,filterTriggerProps:Mi,inputProps:Mi,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new fl,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Mi,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}let eg=/*#__PURE__*/ y.createContext(null);function tg(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function ng(e,t){return e===`list-navigation`||tg(e,t)}let rg=Di(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,onItemHighlighted:a,defaultOpen:o=!1,disabled:s=!1,modal:c,loopFocus:l=!0,orientation:u=`vertical`,actionsRef:d,closeParentOnEsc:f=!1,handle:p,triggerId:m,defaultTriggerId:h=null,highlightItemOnHover:g=!0,isSubmenu:_=!1,virtualFocus:v=!1,virtualFocusRef:b,allowEscape:x=!0,resetOnPointerLeave:S=!0}=e,C=Um(!0),w=Vm(!0),T=Jh(!0),E=w?.store,D=w?.virtualFocus??!1,O=y.useMemo(()=>_&&E?{type:`menu`,store:E}:T?{type:`menubar`,context:T}:C&&!E?{type:`context-menu`,context:C}:{type:void 0},[C,E,T,_]),k=_f(),j=_f(),[M,N]=y.useState(void 0),P=(M??j)||void 0,F=hl(),I=O.type===`menu`?O.store:void 0,L=(n??o)&&I?.state.transitionStatus===`starting`,R=Si(()=>L?I?.state.instantType:void 0).current,z=Si(()=>{let e=new Zh({open:o,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:O,disabled:s,highlightItemOnHover:g,modal:O.type===void 0?c:void 0,rootId:k,instantType:R},P,F!=null);return e.context.virtualFocusRef=b,e}).current;z.useControlledProp(`openProp`,n),z.useControlledProp(`triggerIdProp`,m),z.useContextCallback(`onOpenChangeComplete`,i);let B=z.useState(`floatingTreeRoot`),V=_l(B),H=z.useState(`open`),U=z.useState(`activeTriggerElement`),ee=z.useState(`positionerElement`),te=z.useState(`hoverEnabled`),ne=z.useState(`disabled`),W=z.useState(`lastOpenChangeReason`),re=z.useState(`parent`),ie=z.useState(`activeIndex`),G=z.useState(`keyboardOpen`),K=z.useState(`payload`),q=z.useState(`floatingParentNodeId`),ae=y.useRef(null),oe=y.useRef(re.type!==`context-menu`),se=zi(),ce=y.useRef(!0),le=zi(),J=q!=null,{openMethod:ue,triggerProps:de}=qp(H);z.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:re.type===void 0?c:void 0,openMethod:ue,rootId:k}),uu(z);let{forceUnmount:fe,transitionStatus:pe}=du(H,z,()=>{z.set(`allowMouseEnter`,!1)},L),me=Zl(z.context.popupRef);y.useEffect(()=>{if(R===void 0)return;let e=()=>{z.state.instantType===R&&z.set(`instantType`,void 0)};if(!H){e();return}if(pe!==void 0)return;if(z.context.popupRef.current==null){e();return}let t=new AbortController;return me(e,t.signal),()=>{t.abort()}},[R,H,pe,me,z]),X(()=>{C&&!w?z.update({parent:{type:`context-menu`,context:C},floatingNodeId:V,floatingParentNodeId:F}):(w||!z.select(`activeTriggerElement`))&&z.update({floatingNodeId:V,floatingParentNodeId:F})},[C,w,V,F,U,z]),y.useEffect(()=>{H||(ae.current=null),re.type===`context-menu`&&(H?se.start(500,()=>{oe.current=!0}):(se.clear(),oe.current=!1))},[se,H,re.type]),X(()=>{!H&&!te&&z.set(`hoverEnabled`,!0)},[H,te,z]);let he=$((e,t)=>{let n=t.reason;if(!e&&!z.select(`open`)||H===e&&t.trigger===U&&W===n)return;let i=su(t);if(!e&&t.trigger==null&&(t.trigger=U??void 0),r?.(e,t),t.isCanceled)return;z.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!ce.current)return;e&&n===`trigger-focus`?(ce.current=!1,le.start(300,()=>{ce.current=!0})):(ce.current=!0,le.clear());let o=!e&&(n===`escape-key`||n==null);ae.current=t.event;let s=ou(z.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&ng(n,a),s.instantType=re.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:tg(n,a)?`click`:o?`dismiss`:void 0,z.update(s)}),ge=Kl({popupStore:z,floatingRootContext:z.state.floatingRootContext,floatingId:P,nested:F!=null,onOpenChange:he}),_e=ge.context.events;X(()=>{let e=({open:e,eventDetails:t})=>he(e,t);return _e.on(`setOpen`,e),()=>{_e?.off(`setOpen`,e)}},[_e,he]),X(()=>z.subscribeToParentMenu(),[z]);let ve=y.useCallback(()=>{z.setOpen(!1,Q(ko))},[z]);y.useImperativeHandle(d,()=>({unmount:fe,close:ve}),[fe,ve]);let ye;re.type===`context-menu`&&(ye=re.context),y.useImperativeHandle(ye?.positionerRef,()=>ee,[ee]),y.useImperativeHandle(ye?.actionsRef,()=>({setOpen:he}),[he]);let be=Fl(ge,{enabled:!ne,bubbles:{escapeKey:f&&re.type===`menu`},outsidePress(){return re.type!==`context-menu`||ae.current?.type===`contextmenu`||oe.current},externalTree:J?B:void 0}),xe=jf(),Se=td(ge,{enabled:!ne,listRef:z.context.itemDomElements,activeIndex:ie,virtual:v,nested:re.type===`menubar`||!v&&re.type!==void 0,parentOrientation:re.type===`menubar`?re.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?G:void 0,allowEscape:v&&l&&x,orientation:u,triggerOrientation:v?`vertical`:u,rtl:xe===`rtl`,disabledIndices:ji,onNavigate(e,t){z.setActiveIndex(e,Yh(t),t?.nativeEvent)},openOnArrowKeyDown:re.type!==`context-menu`&&!(v&&_),externalTree:!v&&J?B:void 0,nestedReturnFocusRef:I?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:S}),Ce=y.useCallback(e=>{z.context.typingRef.current=e},[z]),we=nd(ge,{enabled:!ne&&!v,listRef:z.context.itemLabels,elementsRef:z.context.itemDomElements,activeIndex:ie,resetMs:500,onMatch:(e,t)=>{H&&e!==ie&&z.setActiveIndex(e,To,t.nativeEvent)},onTyping:Ce}),Te=$(a),Ee=y.useRef(-1),De=$(()=>{let e=z.state.activeIndex,t=e===null?void 0:z.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(Ee.current===n&&z.context.reportedItem===t)return;Ee.current=n,z.context.reportedItem=t,v&&z.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=z.context;z.context.highlightReason=po,z.context.highlightEvent=void 0,a&&Te(t,fo(r,i,{label:t===void 0?void 0:z.context.itemLabels.current[n]??void 0}))});X(()=>{De()},[ie,De]);let Oe=y.useMemo(()=>{if(!v)return Se.reference;if(!Se.trigger)return Mi;let{onFocus:e,...t}=Se.trigger;return t},[v,Se.reference,Se.trigger]);z.useSyncedValue(`inputProps`,v?Se.reference??Mi:Mi);let ke=y.useMemo(()=>{let e=Fc(we.reference,Oe,be.reference,{onMouseMove(){z.set(`allowMouseEnter`,!0)}},de);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=H,e},[z,we.reference,Oe,be.reference,de,H]),Ae=y.useMemo(()=>{let e=Fc(Se.trigger,be.trigger,de);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[Se.trigger,be.trigger,de]);Si(()=>(z.update({inactiveTriggerProps:Ae}),null)),fu(z,{floatingRootContext:ge,activeTriggerProps:ke,inactiveTriggerProps:Ae,popupProps:y.useMemo(()=>Fc(eu,{onMouseMove(){z.set(`allowMouseEnter`,!0),re.type===`menu`&&z.set(`hoverEnabled`,!1)},onClick(){z.select(`hoverEnabled`)&&z.set(`hoverEnabled`,!1)},onKeyDown(e){let t=z.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},we.floating,Se.floating,be.floating),[re.type,z,we.floating,Se.floating,be.floating]),itemProps:Se.item??Mi});let je=y.useMemo(()=>({store:z,parent:O,orientation:u,loopFocus:l,allowEscape:x,defaultFloatingId:j,setRenderedFloatingId:N,virtualFocus:v,parentVirtualFocus:D,syncHighlightedItem:De}),[z,O,u,l,x,j,v,D,De]),Me=typeof t==`function`?t({payload:K}):t,Ne=/*#__PURE__*/ (0,A.jsxs)(Bm.Provider,{value:je,children:[p&&/*#__PURE__*/ (0,A.jsx)(ru,{handle:p,store:z}),Me]});return(re.type===void 0||re.type===`context-menu`)&&(Ne=/*#__PURE__*/ (0,A.jsx)(yl,{externalTree:B,children:Ne})),Ne});function ig(e){let t=y.useContext(eg);if(t===null)return/*#__PURE__*/ (0,A.jsx)(rg,{...e});let n=t.Root;return/*#__PURE__*/ (0,A.jsx)(eg.Provider,{value:null,children:/*#__PURE__*/ (0,A.jsx)(n,{...t.options,...e})})}let ag={};function og(e){Vm();let t=y.useContext(eg);if(t!==null){let n=t.SubmenuRoot;return/*#__PURE__*/ (0,A.jsx)(eg.Provider,{value:null,children:/*#__PURE__*/ (0,A.jsx)(n,{...t.options,...e})})}return/*#__PURE__*/ (0,A.jsx)(gh.Provider,{value:ag,children:/*#__PURE__*/ (0,A.jsx)(rg,{...e,isSubmenu:!0})})}function sg(e,t){let n=cg(t);return e.clientX>=n.left-5&&e.clientX<=n.right+5&&e.clientY>=n.top-5&&e.clientY<=n.bottom+5}function cg(e){let t=e.getBoundingClientRect(),n=la(e);if(ea)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}function lg(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=up(),{ref:i,index:a}=rh(e),o=n===a,s=y.useRef(null),c=Fo(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function ug(e){let{render:t,className:n,style:r,state:i=Mi,props:a=ji,refs:o=ji,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=lg({metadata:s});return Jc(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function dg(e){if(pa(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!Ta(e))return dg(Oa(e))}function fg(e,t){function n(n,r,i){let a=n.currentTarget;b.flushSync(()=>{e.setOpen(!1,Q(So,n.nativeEvent,a))}),rc(a.isConnected?a:t.current,r,i)?.focus()}function r(t){n(t,-1,e.select(`positionerElement`))}function i(t){let r=e.select(`positionerElement`);r&&ic(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function pg(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=y.useRef(!1);return y.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,Zo(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:Mi,[t,n,r])}let mg=Oi(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=Vm(!0),h=Lu(d)??m?.store;if(!h)throw Error(Pi(85));let g=_f(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),b=h.useState(`isOpenedByTrigger`,g),x=h.useState(`triggerControlsId`,g),S=y.useRef(null),C=gg(),w=up(!0),T=gl(),E=y.useMemo(()=>T??new fl,[T]),{registerTrigger:D,isMountedByThisTrigger:O}=lu(g,S,h,{payload:f,closeDelay:u,parent:C,floatingTreeRoot:E,floatingNodeId:_l(E),floatingParentNodeId:hl(),keyboardEventRelay:w?.relayKeyboardEvent}),k=C.type===`menubar`,j=h.useState(`disabled`),M=a||j||k&&C.context.disabled,{getButtonProps:N,buttonRef:P}=pp({disabled:M,native:o});y.useEffect(()=>{!b&&C.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,b,C.type]);let F=y.useRef(null),I=zi(),L=$(e=>{if(!F.current)return;I.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;Z(F.current,t)||Z(h.select(`positionerElement`),t)||t===F.current||t!=null&&dg(t)===h.select(`rootId`)||sg(e,F.current)||E.events.emit(`close`,{domEvent:e,reason:Do})});y.useEffect(()=>{let e=Zo(F.current);if(b&&h.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,L,{once:!0}),()=>{e.removeEventListener(`mouseup`,L)}},[b,L,h]);let R=k&&C.context.hasSubmenuOpen,z=Ju(v,{enabled:(c??R)&&!M&&(!k||R&&!O),handleClose:cd({blockPointerEvents:!k}),mouseOnly:!0,move:!1,restMs:C.type===void 0?l:void 0,delay:{close:u},triggerElementRef:S,externalTree:E,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),B=hg(b,h.select(`lastOpenChangeReason`)),V=kl(v,{enabled:!M,event:b&&k?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:C.type===void 0&&B}),H=Bu(v,{enabled:!M&&R}),U=pg({open:b,enabled:k,mouseDownAction:`open`}),ee=y.useMemo(()=>Fc(H.reference,V.reference),[H.reference,V.reference]),te=h.useState(`triggerProps`,O),ne=h.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:W,handleFocusTargetFocus:re}=fg(h,S),ie={disabled:M,open:b},G=[F,t,P,D,S],K=[ee,z??Mi,te,{"aria-haspopup":`menu`,"aria-controls":x,id:g,onMouseDown:e=>{h.select(`open`)||(I.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),Zo(e.currentTarget).addEventListener(`mouseup`,L,{once:!0}))}},ne,k?{role:`menuitem`}:{},U,p,N],q=Jc(`button`,e,{enabled:!k,stateAttributesMapping:Ja,state:ie,ref:G,props:K});return k?/*#__PURE__*/ (0,A.jsx)(ug,{tag:`button`,render:n,className:r,style:i,state:ie,refs:G,props:K,stateAttributesMapping:Ja}):b?/*#__PURE__*/ (0,A.jsxs)(y.Fragment,{children:[/*#__PURE__*/ (0,A.jsx)(ts,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:W},`${g}-pre-focus-guard`),/*#__PURE__*/ (0,A.jsx)(y.Fragment,{children:q},g),/*#__PURE__*/ (0,A.jsx)(ts,{ref:h.context.triggerFocusTargetRef,onFocus:re},`${g}-post-focus-guard`)]}):/*#__PURE__*/ (0,A.jsx)(y.Fragment,{children:q},g)});function hg(e,t){let n=zi(),[r,i]=y.useState(!1);return X(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function gg(){let e=Jh(!0);return y.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}let _g=/*#__PURE__*/ y.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return Jc(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});function vg(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}let yg={"aria-expanded":void 0},bg=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,label:a,id:o,nativeButton:s=!1,openOnHover:c=!0,delay:l=100,closeDelay:u=0,disabled:d=!1,...f}=e,p=Vm(!0);if(p?.parent.type!==`menu`)throw Error(Pi(37));let m=zm(),h=_h(),{store:g,parentVirtualFocus:_}=p,v=p.parent.store,b=rh({guess:!0,label:a}),x=_f(o),S=g.useState(`open`),C=y.useRef(!1),w=g.useState(`positionerElement`),T=g.useState(`floatingRootContext`),E=g.useState(`floatingTreeRoot`),D=g.useState(`triggerPopupId`,x),O=au(x,g),k=$(e=>{O(e);let t=g.select(`activeTriggerElement`);e!==null&&g.select(`open`)&&(t===e||g.select(`activeTriggerId`)==null)&&g.update({activeTriggerId:x??null,activeTriggerElement:e,closeDelay:u})}),A=y.useRef(null),j=y.useCallback(e=>{A.current=e,g.set(`activeTriggerElement`,e)},[g]);X(()=>(k(A.current),()=>k(null)),[k,x,g]),X(()=>{if(!S||!w)return;function e(e){Pa(e)===g.context.beforeContentFocusGuardRef.current&&(C.current=e.relatedTarget===A.current)}return w.addEventListener(`focusout`,e,!0),()=>{C.current=!1,w.removeEventListener(`focusout`,e,!0)}},[S,w,g]),g.useSyncedValue(`closeDelay`,u);let M=g.useState(`disabled`),N=v.useState(`disabled`),P=d||M||N,F=v.useState(`itemProps`),I=v.useState(`isActive`,b.index),L=y.useMemo(()=>({type:`submenu-trigger`,setActive(e){v.select(`highlightItemOnHover`)&&v.setActiveIndex(b.index,Eo,e)}}),[v,b.index]),{getItemProps:R,itemRef:z}=eh({closeOnClick:!1,disabled:P,highlighted:I,id:x,store:g,typingRef:v.context.typingRef,nativeButton:s,itemMetadata:L,nodeId:m?.context.nodeId}),B=Ju(T,{enabled:g.useState(`hoverEnabled`)&&c&&!P,handleClose:cd({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:l,delay:{open:l,close:u},shouldOpen:l>0?()=>v.select(`allowMouseEnter`):void 0,triggerElementRef:A,externalTree:E,isClosing:()=>g.select(`transitionStatus`)===`ending`,guardStaleOpen:!0}),V=kl(T,{enabled:!P,event:`mousedown`,toggle:!0,ignoreMouse:c,stickIfOpen:c}).reference??Mi,H=g.useState(`triggerProps`,!0);delete H.id;let U={disabled:P,highlighted:I,open:S},ee=g.useState(`openMethod`),te=g.useState(`lastOpenChangeReason`)===`list-navigation`||ee===`keyboard`,ne=S&&te&&$i,W=h?.onTriggerKeyDown?{onKeyDown:h.onTriggerKeyDown}:void 0;return Jc(`div`,e,{state:U,stateAttributesMapping:qa,props:[V,B,H,W,F,ne?yg:void 0,{"aria-controls":D,tabIndex:_||!(S||I)?-1:0,onFocus(e){g.select(`open`)&&C.current&&(C.current=!1,g.setOpen(!1,Q(So,e.nativeEvent)))},onBlur(){I&&v.setActiveIndex(null,po)}},f,R],ref:[t,b.ref,z,k,j]})}),xg=/*#__PURE__*/ y.forwardRef(function(e,t){let n=Ym(e,t,`submenu-trigger`);if(!n.visible)return null;let r=n.props?Fc(n.props,e):e;return/*#__PURE__*/ (0,A.jsx)(bg,{...r,ref:n.ref})});function Sg(e){return Array.isArray(e)?e.map(e=>Sg(e)).join(`,`):e==null?``:String(e)}function Cg(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function wg(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function Tg(e){return wg(e?.[0])}function Eg(e){return Tg(e)?e.flatMap(e=>e.items):e}function Dg(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(Tg(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function Og(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return Cg(e)}function kg(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?Cg(e.value):Cg(e)}let Ag=/* @__PURE__ */ new Map;function jg(e={}){let{locale:t,...n}=e,r={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...n},i=`${Sg(t)}|${JSON.stringify(r)}`,a=Ag.get(i);if(a)return a;let o=new Intl.Collator(t,r),s={contains(e,t,n){if(!t)return!0;let r=Og(e,n);for(let e=0;e<=r.length-t.length;e+=1)if(o.compare(r.slice(e,e+t.length),t)===0)return!0;return!1},startsWith(e,t,n){if(!t)return!0;let r=Og(e,n);return o.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=Og(e,n),i=t.length;return r.length>=i&&o.compare(r.slice(r.length-i),t)===0}};return Ag.set(i,s),s}function Mg(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=null;for(;t.nextNode();){let e=t.currentNode;e.nodeValue!==``&&(n=e)}return n}function Ng(e=!0){let t=zi(),n=y.useRef(null);return y.useEffect(()=>{if(!e||Ki)return;let r=n.current;if(r==null)return;let i=Mg(r);if(i==null)return;let a=i.data,o=`${a}⁠`;return i.nodeValue=o,t.start(200,()=>{i.nodeValue===o&&(i.nodeValue=a)}),()=>{t.clear(),i.nodeValue===o&&(i.nodeValue=a)}},[e,n,t]),n}lt(),ti(ct);function Pg({items:e,label:t,icon:n=`dots-three`,align:r=`end`,triggerClassName:i}){let[a,o]=y.useState(null),s=e.filter(e=>!e.danger),c=e.filter(e=>!!e.danger),l=e=>/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[e.icon?/* @__PURE__ */ (0,A.jsx)(fi,{icon:e.icon,size:16}):/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-menu-noicon`}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-menu-label`,children:e.label}),e.shortcut?/* @__PURE__ */ (0,A.jsx)(`kbd`,{className:`ui-menu-kbd`,children:e.shortcut}):null]});return/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsxs)(ig,{children:[/* @__PURE__ */ (0,A.jsx)(mg,{className:M(`ui-iconbtn`,`ui-menu-trigger`,i),"aria-label":t||w(`更多操作`),children:/* @__PURE__ */ (0,A.jsx)(fi,{icon:n,size:20})}),/* @__PURE__ */ (0,A.jsx)(Dh,{children:/* @__PURE__ */ (0,A.jsx)(Lh,{className:`ui-float`,side:`bottom`,align:r,sideOffset:4,children:/* @__PURE__ */ (0,A.jsxs)(wh,{className:`ui-menu`,children:[s.map((e,t)=>/* @__PURE__ */ (0,A.jsx)(ph,{disabled:e.disabled,className:`ui-menu-item`,onClick:()=>e.onSelect?.(),children:l(e)},t)),c.length&&s.length?/* @__PURE__ */ (0,A.jsx)(_g,{className:`ui-menu-sep`}):null,c.map((e,t)=>/* @__PURE__ */ (0,A.jsx)(ph,{disabled:e.disabled,className:`ui-menu-item is-danger`,onClick:()=>o(e),children:l(e)},`d`+t))]})})})]}),c.length?/* @__PURE__ */ (0,A.jsx)(Zp,{open:!!a,onClose:()=>o(null),title:a?a.confirm?.title??w(`{label}?`,{label:a.label}):``,tone:`danger`,confirmLabel:a?.confirm?.confirmLabel??a?.label??``,onConfirm:()=>{let e=a;o(null),e?.onSelect?.()},children:a?.confirm?.body}):null]})}function Fg({actions:e,className:t}){let n=y.useRef(null);Lm(n);let r=e.find(e=>e.primary)??e.find(e=>!e.danger),i=e.filter(e=>e!==r),a=(e,t,n)=>e.danger?/* @__PURE__ */ (0,A.jsx)(Xp,{variant:`danger`,confirm:e.confirm,icon:e.icon,onClick:e.onClick,disabled:e.disabled,children:e.label},t):/* @__PURE__ */ (0,A.jsx)(Xp,{variant:e===r?`primary`:`secondary`,icon:e.icon,onClick:e.onClick,disabled:e.disabled,className:n?`ui-actbar-main`:void 0,children:e.label},t),o=i.map(e=>e.danger?{label:e.label,icon:e.icon,onSelect:e.onClick,disabled:e.disabled,danger:!0,confirm:e.confirm}:{label:e.label,icon:e.icon,onSelect:e.onClick,disabled:e.disabled});return/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:n,className:M(`ui-actbar`,t),children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-actbar-wide`,children:(r?[r,...i]:i).map((e,t)=>a(e,t,!1))}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-actbar-narrow`,children:[r?a(r,0,!0):null,i.length?/* @__PURE__ */ (0,A.jsx)(Pg,{label:w(`更多操作`),triggerClassName:`ui-actbar-more`,items:o}):null]})]})}ir(),ti(rr);let Ig={info:`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18zM12 11v5M12 7.5v.5`,success:`M5 12.5l4.5 4.5L19 7`,warning:`M12 4l9 16H3zM12 10v4M12 17v.5`,danger:`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18zM12 8v5M12 16.5v.5`};function Lg({tone:e=`info`,title:t,children:n,actionLabel:r,onAction:i,onDismiss:a,className:o}){let s=Ig[e]?e:`info`,c=(s===`info`||s===`success`)&&a;return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-alert`,`ui-alert-`+s,o),role:s===`danger`?`alert`:`status`,children:[/* @__PURE__ */ (0,A.jsx)(Y,{d:Ig[s],className:`ui-alert-icon`}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-alert-content`,children:[t?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-alert-title`,children:t}):null,n?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-alert-body`,children:n}):null]}),r?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-btn ui-btn-secondary ui-alert-action`,onClick:i,children:r}):null,c?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-alert-close`,"aria-label":w(`關閉提示`),onClick:a,children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`,size:16})}):null]})}let Rg={draft:{label:`草稿`,fill:``},doing:{label:`進行中`,fill:`M12 4a8 8 0 0 1 0 16z`},review:{label:`審核中`,fill:`M12 4a8 8 0 0 1 8 8h-8z`},done:{label:`完成`,fill:`M12 4a8 8 0 1 1 0 16a8 8 0 1 1 0-16z`},fail:{label:`失敗`,fill:`M12 4a8 8 0 1 1 0 16a8 8 0 1 1 0-16z`}};function zg({status:e,variant:t=`chip`,children:n,className:r}){let i=Rg[e]?e:`draft`;return/* @__PURE__ */ (0,A.jsxs)(`span`,{className:M(`ui-badge`,`ui-badge-`+i,t===`dot`&&`is-dot`,r),children:[/* @__PURE__ */ (0,A.jsxs)(`svg`,{className:`ui-badge-mark`,width:15,height:15,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsx)(`circle`,{cx:12,cy:12,r:8,fill:`none`,stroke:`currentColor`,strokeWidth:2.5}),Rg[i].fill?/* @__PURE__ */ (0,A.jsx)(`path`,{d:Rg[i].fill,fill:`currentColor`}):null]}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-badge-text`,children:n||w(Rg[i].label)})]})}let Bg={money:0,percent:1,size:1,count:0},Vg=e=>String(e).padStart(2,`0`);function Hg(){return S.locale}function Ug(e,t={}){if(!e)return``;let n=t.weekday!==!1;return t.long?new Intl.DateTimeFormat(S.locale,{year:`numeric`,month:`long`,day:`numeric`,weekday:n?`long`:void 0}).format(e):O()?o_(e)+(n?`(${new Intl.DateTimeFormat(`zh-TW`,{weekday:`narrow`}).format(e)})`:``):new Intl.DateTimeFormat(S.locale,{year:`numeric`,month:`2-digit`,day:`2-digit`,weekday:n?`short`:void 0}).format(e)}function Wg(e){return e?new Intl.DateTimeFormat(S.locale,O()?{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}:{hour:`numeric`,minute:`2-digit`}).format(e):``}function Gg(e,t){return e?`${Ug(e,t)} ${Wg(e)}`:``}function Kg(e,t=/* @__PURE__ */ new Date){if(!e)return``;let n=(t.getTime()-e.getTime())/1e3;if(n<0||n>=604800)return Gg(e);let r=new Intl.RelativeTimeFormat(S.locale,{numeric:`auto`});return n<60?r.format(0,`second`):n<3600?r.format(-Math.floor(n/60),`minute`):n<86400?r.format(-Math.floor(n/3600),`hour`):r.format(-Math.floor(n/86400),`day`)}function qg(e){return new Intl.DateTimeFormat(S.locale,{year:`numeric`,month:`long`}).format(e)}function Jg(){if(O())return 0;try{let e=new Intl.Locale(S.locale),t=e.getWeekInfo?e.getWeekInfo():e.weekInfo;if(t?.firstDay)return t.firstDay%7}catch{}return 0}function Yg(){let e=Jg(),t=new Intl.DateTimeFormat(S.locale,{weekday:`narrow`});return Array.from({length:7},(n,r)=>t.format(new Date(2026,10,1+(e+r)%7)))}function Xg(e,t){let n=typeof t==`number`?t:t?Bg[t]:0;return new Intl.NumberFormat(S.locale,{minimumFractionDigits:n,maximumFractionDigits:n}).format(e)}function Zg(e,t=1){return new Intl.NumberFormat(S.locale,{style:`percent`,minimumFractionDigits:t,maximumFractionDigits:t}).format(e/100)}function Qg(e,t){let n=t??e;if(Math.abs(n)<1e4)return Xg(e);if(/^zh/i.test(S.locale)){let r=Math.abs(n),[i,a,o]=Math.round(r/1e3)>=1e5?[`億`,1e8,2]:[`萬`,1e4,1],s=new Intl.NumberFormat(S.locale,{maximumFractionDigits:o}).format(r/a),c=e<0?`-`:``;if(t===void 0)return`${c}${s} ${i}`;let l=(s.split(`.`)[1]||``).length;return`${c}${new Intl.NumberFormat(S.locale,{minimumFractionDigits:l,maximumFractionDigits:l}).format(Math.abs(e)/a)} ${i}`}let r=new Intl.NumberFormat(S.locale,{notation:`compact`,maximumFractionDigits:1});if(t===void 0)return r.format(e);let i=r.formatToParts(n),a=``,o=``;for(let e of i)e.type===`integer`&&(a+=e.value),e.type===`fraction`&&(a+=`.`+e.value,o=e.value);let s=10**Math.round(Math.log10(Math.abs(n)/(parseFloat(a)||1))),c=new Intl.NumberFormat(S.locale,{minimumFractionDigits:o.length,maximumFractionDigits:o.length}).format(Math.abs(e)/s),l=!1,u=i.map(e=>e.type===`integer`||e.type===`group`||e.type===`decimal`||e.type===`fraction`?l?``:(l=!0,c):e.value).join(``);return(e<0&&n>=0?`-`:``)+u}function $g(e,t={}){let n=t.currency||S.currency,r=t.compact?Qg(Math.abs(e),t.like===void 0?void 0:Math.abs(t.like)):Xg(Math.abs(e),`money`);return O()&&n===`TWD`?`${e<0?`-`:``}NT$ ${r}`:t.compact?`${e<0?`-`:``}${r} ${n}`:new Intl.NumberFormat(S.locale,{style:`currency`,currency:n,currencyDisplay:n===`TWD`?`symbol`:`narrowSymbol`,minimumFractionDigits:0,maximumFractionDigits:n===`TWD`||n===`JPY`?0:2}).format(e)}function e_(e){return e==null||Number.isNaN(e)?``:Math.round(e/1024)<1024?Xg(e===0?0:Math.max(1,Math.round(e/1024)))+` KB`:Math.round(e/1048576*10)<10240?Xg(e/1048576,1)+` MB`:Xg(e/1073741824,1)+` GB`}function t_(e){if(e==null||Number.isNaN(e)||e<0||!Number.isFinite(e))return`—`;let t=Math.round(e),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n?`${n}:${Vg(r)}:${Vg(i)}`:`${r}:${Vg(i)}`}function n_(e,t={}){let n=t.head??1,r=t.tail??2,i=String(e??``).split(`/`);return i.length>n+r?`${i.slice(0,n).join(`/`)}/…/${i.slice(-r).join(`/`)}`:String(e??``)}function r_(e,t,n){return w(n?`{n} / {total} {unit}`:`{n} / {total}`,{n:Xg(e),total:Xg(t),unit:n??``})}function i_(e,t,n){return w(n?`{total} {unit}中的 {n} {unit}`:`{total} 中的 {n}`,{n:Xg(e),total:Xg(t),unit:n??``})}let a_={locale:Hg,date:Ug,time:Wg,dateTime:Gg,relative:Kg,month:qg,weekdays:Yg,firstDay:Jg,number:Xg,percent:Zg,compact:Qg,money:$g,fileSize:e_,duration:t_,path:n_,fraction:r_,fractionLabel:i_},o_=e=>e?`${e.getFullYear()}/${Vg(e.getMonth()+1)}/${Vg(e.getDate())}`:``;function s_(e){let t=/^(\d{4})\/(\d{1,2})\/(\d{1,2})$/.exec(e||``);if(!t)return null;let n=new Date(+t[1],t[2]-1,+t[3]);return n.getMonth()===t[2]-1?n:null}let c_=(e,t)=>!!e&&!!t&&e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),l_=(e,t)=>new Date(e.getFullYear(),e.getMonth(),e.getDate()+t);function u_(e,t){let[n,r]=y.useState(+!!L());return y.useEffect(()=>{if(L())return;let e=null,n=0,i=a=>{e??=a;let o=Math.min(1,(a-e)/t);r(1-(1-o)**3),o<1&&(n=requestAnimationFrame(i))};return n=requestAnimationFrame(i),()=>cancelAnimationFrame(n)},[e,t]),n}let d_=e=>Math.min(3,(String(+(e/4).toPrecision(6)).split(`.`)[1]??``).length);function f_(e){let t=e=>e[0].toFixed(1)+`,`+e[1].toFixed(1);if(e.length<2)return e.length?`M`+t(e[0]):``;let n=`M`+t(e[0]);for(let r=0;r<e.length-1;r++){let i=e[r-1]||e[r],a=e[r],o=e[r+1],s=e[r+2]||o;n+=` C${t([a[0]+(o[0]-i[0])/6,a[1]+(o[1]-i[1])/6])} ${t([o[0]-(s[0]-a[0])/6,o[1]-(s[1]-a[1])/6])} ${t(o)}`}return n}let p_=[`var(--chart-1)`,`var(--chart-2)`,`var(--chart-3)`,`var(--chart-4)`],m_=e=>p_[e%p_.length],h_=[0,.25,.5,.75,1];function g_(e,t,n){let r=t.compact!==!1&&Math.abs(t.value)>=1e4;return t.format===`money`?a_.money(e,{compact:r,currency:t.currency,like:t.value}):t.format===`percent`?a_.number(e,n||1):r?a_.compact(e,t.value):a_.number(e,n)}function __(e,t){y.useLayoutEffect(()=>{let t=e.current;if(!t)return;let n=()=>{t.style.fontSize=``;let e=parseFloat(getComputedStyle(t).fontSize)||31,n=t.querySelector(`.ui-kpi-sizer`),r=t.querySelector(`.ui-kpi-unit`),i=(n?n.scrollWidth:0)+(r?r.offsetWidth+4:0),a=t.clientWidth,o=i>a&&a>0?Math.max(20,Math.floor(e*a/i)):null;t.style.fontSize=o?o+`px`:``};n();let r=typeof ResizeObserver==`function`?new ResizeObserver(n):null;return r?.observe(t.parentNode||t),()=>r?.disconnect()},t)}function v_({title:e,rows:t,style:n}){return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-chart-tip`,style:n,children:[e?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-chart-tip-title`,children:e}):null,t.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-chart-tip-row`,children:[e.color?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-chart-swatch`,style:{background:e.color}}):null,/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-chart-tip-name`,children:e.name}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-chart-tip-val`,children:e.value})]},t))]})}function y_(e){let t=10**Math.floor(Math.log10(e||1)),n=Math.ceil(e/t);return(n<=2?2:n<=4?4:n<=5?5:n<=8?8:10)*t}function b_(e,t,n){if(e.altKey||e.metaKey||e.ctrlKey||!n)return null;let r=Math.max(0,t),i=e.key===`ArrowRight`?Math.min(n-1,r+1):e.key===`ArrowLeft`?Math.max(0,r-1):e.key===`Home`?0:e.key===`End`?n-1:null;return i!=null&&e.preventDefault(),i}function x_({data:e,label:t,unit:n,decimals:r,max:i,className:a}){let[o,s]=y.useState(-1),c=i||y_(Math.max(1,...e.map(e=>e.value))),l=n?` `+n:``,u=t=>{s(t),bi(e[t].label+w(`:`)+a_.number(e[t].value,r)+l)};return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-chart`,a),children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-bars`,role:`img`,"aria-label":t,"aria-description":w(`左右方向鍵查看每一項的數值`),tabIndex:e.length?0:void 0,onMouseLeave:()=>s(-1),onFocus:()=>o<0&&e.length&&u(0),onBlur:()=>s(-1),onKeyDown:t=>{let n=b_(t,o,e.length);n!=null&&u(n)},children:[h_.map((e,t)=>/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-bars-grid`,!t&&`is-axis`),style:{bottom:e*100+`%`},children:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-chart-tick`,children:a_.number(e*c,d_(c))})},`g`+t)),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-bars-row`,children:e.map((e,t)=>{let n=e.value/c*100+`%`;return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-bar-slot`,onMouseEnter:()=>s(t),children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-bar`,style:{height:n,animationDelay:t*40+`ms`,opacity:o>=0&&o!==t?.55:1}}),o===t?/* @__PURE__ */ (0,A.jsx)(v_,{style:{bottom:`calc(${n} + 8px)`,left:`50%`,transform:`translateX(-50%)`,whiteSpace:`nowrap`},rows:[{name:e.label,value:a_.number(e.value,r)+l}]}):null]},t)})})]}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-bars-labels`,children:e.map((e,t)=>/* @__PURE__ */ (0,A.jsx)(`span`,{children:ne(e.short||e.label)},t))})]})}Ne(),Fe(),ti(Me,Pe);function S_({focus:e,onPick:t,onHover:n,dayState:r}){let[i,a]=y.useState(()=>{let t=e||/* @__PURE__ */ new Date;return new Date(t.getFullYear(),t.getMonth(),1)}),o=/* @__PURE__ */ new Date,s=i.getFullYear(),c=i.getMonth(),[l,u]=y.useState(()=>e||o),d=l.getFullYear()===s&&l.getMonth()===c?l:new Date(s,c,Math.min(l.getDate(),new Date(s,c+1,0).getDate())),f=y.useRef(null),p=y.useRef(!1);y.useEffect(()=>{p.current&&(p.current=!1,f.current?.querySelector(`.ui-cal-day[tabindex="0"]`)?.focus())});let m=e=>{let t=e<d?-1:1;for(let n=0;n<31&&r?.(e)?.disabled;n++)e=l_(e,t);u(e),(e.getMonth()!==c||e.getFullYear()!==s)&&a(new Date(e.getFullYear(),e.getMonth(),1)),p.current=!0,n?.(e)},h=e=>{if(W(e))return;let t=(d.getDay()-a_.firstDay()+7)%7,n=e=>{let t=new Date(d.getFullYear(),d.getMonth()+e+1,0).getDate();return new Date(d.getFullYear(),d.getMonth()+e,Math.min(d.getDate(),t))},r={ArrowLeft:()=>l_(d,-1),ArrowRight:()=>l_(d,1),ArrowUp:()=>l_(d,-7),ArrowDown:()=>l_(d,7),Home:()=>l_(d,-t),End:()=>l_(d,6-t),PageUp:()=>n(-1),PageDown:()=>n(1)};r[e.key]&&(e.preventDefault(),m(r[e.key]()))},g=(new Date(s,c,1).getDay()-a_.firstDay()+7)%7,_=new Date(s,c+1,0).getDate(),v=[...Array(g).fill(null),...Array.from({length:_},(e,t)=>new Date(s,c,t+1))];return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-cal`,children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-cal-head`,children:[/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-cal-nav`,"aria-label":w(`上個月`),onClick:()=>a(new Date(s,c-1,1)),children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-left`,size:16})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-cal-title`,"aria-live":`polite`,children:a_.month(i)}),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-cal-nav`,"aria-label":w(`下個月`),onClick:()=>a(new Date(s,c+1,1)),children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-right`,size:16})})]}),/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:f,className:`ui-cal-grid`,role:`group`,"aria-label":a_.month(i),onKeyDown:h,children:[a_.weekdays().map((e,t)=>/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-cal-wk`,"aria-hidden":`true`,children:e},`w`+t)),v.map((e,i)=>{if(!e)return/* @__PURE__ */ (0,A.jsx)(`span`,{},`e`+i);let a=r?.(e)??{},s=c_(e,o);return/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,disabled:a.disabled,className:M(`ui-cal-day`,a.selected&&`is-sel`,a.inRange&&`is-range`,a.start&&`is-start`,a.end&&`is-end`,s&&`is-today`),"aria-pressed":!!a.selected,"aria-label":a_.date(e,{weekday:!1,long:!0})+(s?w(`(今天)`):``),tabIndex:c_(e,d)?0:-1,onFocus:()=>!c_(e,d)&&u(e),onClick:()=>t?.(e),onMouseEnter:n?()=>n(e):void 0,children:e.getDate()},i)})]})]})}let C_=y.createContext(!1);function w_({as:e=`section`,title:t,actions:n,padding:r=!0,className:i,children:a,...o}){return G(y.useContext(C_),`Card`,`a Card inside a Card gives two shadows. Use one Card and separate its parts with headings or a divider.`),/* @__PURE__ */ (0,A.jsx)(C_.Provider,{value:!0,children:/* @__PURE__ */ (0,A.jsxs)(e,{...o,className:M(`ui-card`,!r&&`is-flush`,i),children:[t||n?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-card-head`,children:[t?/* @__PURE__ */ (0,A.jsx)(`h2`,{className:`ui-card-title`,children:t}):null,n?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-card-actions`,children:n}):null]}):null,a]})})}nr(),ti(tr);function T_({htmlFor:e,id:t,required:n,children:r}){return/* @__PURE__ */ (0,A.jsxs)(e?`label`:`span`,{htmlFor:e,id:t,className:`ui-field-label`,children:[r,n?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-req`,"aria-hidden":`true`,children:` *`}):null]})}function E_({v:e}){let[t,n]=y.useState(e),[r,i]=y.useState(!1);return t!==e&&(n(e),i(e===!0)),e===`mixed`?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-check-dash`}):e?/* @__PURE__ */ (0,A.jsx)(`svg`,{className:M(r&&`ui-draw`),width:14,height:14,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:3.5,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(`path`,{d:pi})}):null}function D_({inline:e}){return/* @__PURE__ */ (0,A.jsx)(Y,{name:`warning-circle`,className:M(`ui-field-icon`,e&&`is-inline`)})}function O_({id:e,error:t,hint:n,className:r}){return t?/* @__PURE__ */ (0,A.jsx)(`div`,{id:e,className:M(`ui-field-error`,r),role:`alert`,children:t},t):n?/* @__PURE__ */ (0,A.jsx)(`div`,{id:e,className:M(`ui-field-hint`,r),children:n}):null}function k_({checked:e,onChange:t,label:n,disabled:r,className:i,...a}){let o=e===`mixed`?`mixed`:!!e;return/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":o,"aria-label":a[`aria-label`],disabled:r,className:M(`ui-check`,o&&`is-on`,i),onClick:()=>t?.(o!==!0),children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-check-box`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(E_,{v:o})}),n?/* @__PURE__ */ (0,A.jsx)(`span`,{children:n}):null]})}let A_=/*#__PURE__*/ y.createContext(void 0);function j_(e){let t=y.useContext(A_);if(t===void 0&&!e)throw Error(Pi(50));return t}let M_={...Iu,instantType:e=>e.instantType,adaptiveOrigin:e=>e.adaptiveOrigin,closeDelay:e=>e.closeDelay};var N_=class extends Du{constructor(e,t,n){let r=new mu;super(P_(e,r,t,n),F_(r),M_)}setOpen=(e,t)=>{let{inlineRectCoordsRef:n}=this.context;cu(this,e,t,{onBeforeDispatch(){let r=t.event;e&&t.reason===`trigger-hover`&&t.trigger&&`clientX`in r&&`clientY`in r&&n.current?.element!==t.trigger&&Wl(n,t.trigger,r.clientX,r.clientY)}})}};function P_(e,t,n,r=!1){return{...Au(t,n,r),instantType:void 0,adaptiveOrigin:void 0,closeDelay:300,...e}}function F_(e){return{popupRef:/*#__PURE__*/ y.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e,inlineRectCoordsRef:{current:void 0}}}function I_(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,onOpenChangeComplete:i,actionsRef:a,handle:o,triggerId:s,defaultTriggerId:c=null,children:l}=e,u=nu((e,r)=>new N_({open:n,openProp:t,activeTriggerId:c,triggerIdProp:s},e,r));u.useControlledProp(`openProp`,t),u.useControlledProp(`triggerIdProp`,s),u.useContextCallback(`onOpenChange`,r),u.useContextCallback(`onOpenChangeComplete`,i);let d=u.useState(`open`),f=u.useState(`activeTriggerId`),p=u.useState(`mounted`),m=u.useState(`payload`);uu(u,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:h}=du(d,u,()=>{u.context.inlineRectCoordsRef.current=void 0});X(()=>{d&&(f??u.set(`payload`,void 0))},[u,f,d]),y.useImperativeHandle(a,()=>({unmount:h,close:()=>u.setOpen(!1,Q(ko))}),[h,u]);let g=d||p||o!=null;return/*#__PURE__*/ (0,A.jsxs)(A_.Provider,{value:u,children:[o&&/*#__PURE__*/ (0,A.jsx)(ru,{handle:o,store:u}),g&&/*#__PURE__*/ (0,A.jsx)(L_,{store:u}),typeof l==`function`?l({payload:m}):l]})}function L_({store:e}){let t=Fl(e.useState(`floatingRootContext`));return fu(e,{activeTriggerProps:t.reference,inactiveTriggerProps:t.trigger,popupProps:t.floating}),null}let R_=Di(function(e){return j_(!0)?/*#__PURE__*/ (0,A.jsx)(I_,{...e}):/*#__PURE__*/ (0,A.jsx)(yl,{children:/*#__PURE__*/ (0,A.jsx)(I_,{...e})})}),z_=/*#__PURE__*/ y.createContext(void 0);function B_(){let e=y.useContext(z_);if(e===void 0)throw Error(Pi(48));return e}let V_=/*#__PURE__*/ y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return j_().useState(`mounted`)||n?/*#__PURE__*/ (0,A.jsx)(z_.Provider,{value:n,children:/*#__PURE__*/ (0,A.jsx)(Tf,{ref:t,...r})}):null}),H_=/*#__PURE__*/ y.createContext(void 0);function U_(){let e=y.useContext(H_);if(e===void 0)throw Error(Pi(49));return e}let W_=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`bottom`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=il,style:g,..._}=e,v=j_(),y=B_(),b=_l(),x=v.useState(`open`),S=v.useState(`mounted`),C=v.useState(`floatingRootContext`),w=v.useState(`instantType`),T=v.useState(`transitionStatus`),E=v.useState(`adaptiveOrigin`),D=v.context.inlineRectCoordsRef,O=Bf({anchor:i,floatingRootContext:C,positionMethod:a,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m,keepMounted:y,nodeId:b,collisionAvoidance:h,adaptiveOrigin:E,inline:Gl(D)}),k=O.update;X(()=>{x&&S&&k()},[x,S,k]);let j=Wf(e,{open:x,side:O.side,align:O.align,anchorHidden:O.anchorHidden,instant:w},{styles:O.positionerStyles,transitionStatus:T,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!S,inert:!x});return/*#__PURE__*/ (0,A.jsx)(H_.Provider,{value:O,children:/*#__PURE__*/ (0,A.jsx)(vl,{id:b,children:j})})}),G_=/*#__PURE__*/ y.forwardRef(function(e,t){let{className:n,render:r,style:i,...a}=e,o=j_(),{side:s,align:c}=U_(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`closeDelay`);return Ql({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),Ku(p,{closeDelay:m}),Jc(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,o.useStateSetter(`popupElement`)],props:[eu,f,Uf(d),a],stateAttributesMapping:Xa})});function K_({children:e,href:t,onClick:n,className:r,look:i=`chip`}){let[a,o]=y.useState(!1),s=y.useCallback(e=>{let t=e?.parentNode;o(!!t&&Array.from(t.childNodes).some(e=>e.nodeType===3&&!!e.textContent?.trim()))},[]),c=!!(t||n),l=M(`ui-code`,c&&`is-link`,c&&a&&`is-inline`,c&&i!==`chip`&&`is-${i}`,typeof e==`string`&&e.length<=24&&`is-short`,r);return t?/* @__PURE__ */ (0,A.jsx)(`a`,{ref:s,className:l,href:t,onClick:n,children:e}):n?/* @__PURE__ */ (0,A.jsx)(`button`,{ref:s,type:`button`,className:l,onClick:n,children:e}):/* @__PURE__ */ (0,A.jsx)(`code`,{className:l,children:e})}let q_=/^[\w./-]+\.[A-Za-z0-9]+:\d+(-\d+)?$/,J_=e=>q_.test(e);function Y_({text:e,refHref:t,onRef:n,isRef:r=J_,as:i=`span`,className:a}){let o=String(e||``).split(/(`[^`]+`)/);return/* @__PURE__ */ (0,A.jsx)(i,{className:a,children:o.map((e,i)=>{if(!e)return null;if(e[0]!=="`"||e.length<2)return e;let a=e.slice(1,-1),o=t&&r(a)&&t(a)||void 0;if(!(r(a)&&(t?o:n)))return/* @__PURE__ */ (0,A.jsx)(K_,{children:a},i);let s=n?e=>{o&&(e.metaKey||e.ctrlKey||e.shiftKey||e.button===1)||(e.preventDefault(),n(a,e))}:void 0;return o?/* @__PURE__ */ (0,A.jsx)(K_,{look:`location`,href:o,onClick:s,children:a},i):s?/* @__PURE__ */ (0,A.jsx)(K_,{look:`location`,onClick:s,children:a},i):/* @__PURE__ */ (0,A.jsx)(K_,{children:a},i)})})}let X_=/*#__PURE__*/ y.createContext(void 0);function Z_(e){let t=y.useContext(X_);if(t===void 0&&!e)throw Error(Pi(47));return t}let Q_={...Iu,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!Iu.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&Iu.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>Iu.isOpenedByTrigger(e,t)&&!e.focusManagerModal,modal:e=>e.modal,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin};var $_=class extends Du{constructor(e,t,n){let r=new mu;super(ev(e,r,t,n),tv(r),Q_)}setOpen=(e,t)=>{let n=t.reason===ho,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=su(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=ou(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.context.stickIfOpen=!0,this.context.stickIfOpenTimeout.start(500,()=>{this.context.stickIfOpen=!1}),b.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function ev(e,t,n,r=!1){let i={...Au(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function tv(e){return{popupRef:/*#__PURE__*/ y.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:/*#__PURE__*/ y.createRef(),beforeTriggerFocusGuardRef:/*#__PURE__*/ y.createRef(),beforeContentFocusGuardRef:/*#__PURE__*/ y.createRef(),stickIfOpenTimeout:new Ri,stickIfOpen:!0,triggerElements:e}}let nv=Di(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=iv(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),pu(u,d),uu(u);let{forceUnmount:m}=du(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),y.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),y.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,Q(ko))}),[m,u]);let h=d||f||s!=null;return/*#__PURE__*/ (0,A.jsxs)(X_.Provider,{value:u,children:[s&&/*#__PURE__*/ (0,A.jsx)(ru,{handle:s,store:u}),h&&/*#__PURE__*/ (0,A.jsx)(av,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function rv(e){return Z_(!0)?/*#__PURE__*/ (0,A.jsx)(nv,{props:e}):/*#__PURE__*/ (0,A.jsx)(yl,{children:/*#__PURE__*/ (0,A.jsx)(nv,{props:e})})}function iv(e,t){let n=nu((e,n)=>new $_(t,e,n));return y.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function av({store:e,modal:t}){let n=Fl(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return fu(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}let ov=Oi(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=Z_(!0),h=Lu(s)??m;if(!h)throw Error(Pi(74));let g=_f(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),b=h.useState(`isOpenedByTrigger`,g),x=h.useState(`triggerPopupId`,g),S=y.useRef(null),{registerTrigger:C,isMountedByThisTrigger:w}=lu(g,S,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),T=h.useState(`isPressOpenedByTrigger`,g),E=h.useState(`isTouchPressOpen`,l),D=h.useState(`hasTriggerFocusGuards`,g),O=Ju(v,{enabled:!a&&l&&!E,mouseOnly:!0,move:!1,handleClose:cd(),restMs:u,delay:{close:d},triggerElementRef:S,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),k=kl(v,{stickIfOpen:$(()=>h.context.stickIfOpen)}),j=Kp(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),M=h.useState(`triggerProps`,w),{getButtonProps:N,buttonRef:P}=pp({disabled:a,native:o}),F={open(e){return T?Ja.open(e):qa.open(e)}},{handlePreFocusGuardFocus:I,handleFocusTargetFocus:L}=fg(h,S),R=Jc(`button`,e,{state:{disabled:a,open:b},ref:[P,t,C,S],props:[k.reference,O,M,j,{[nl]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":b,"aria-controls":x},p,N],stateAttributesMapping:F}),z=/*#__PURE__*/ (0,A.jsx)(y.Fragment,{children:R},g);return D?/*#__PURE__*/ (0,A.jsxs)(y.Fragment,{children:[/*#__PURE__*/ (0,A.jsx)(ts,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:I}),z,/*#__PURE__*/ (0,A.jsx)(ts,{ref:h.context.triggerFocusTargetRef,onFocus:L})]}):z}),sv=/*#__PURE__*/ y.createContext(void 0);function cv(){let e=y.useContext(sv);if(e===void 0)throw Error(Pi(45));return e}let lv=/*#__PURE__*/ y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return Z_().useState(`mounted`)||n?/*#__PURE__*/ (0,A.jsx)(sv.Provider,{value:n,children:/*#__PURE__*/ (0,A.jsx)(ul,{ref:t,...r})}):null}),uv=/*#__PURE__*/ y.createContext(void 0);function dv(){let e=y.useContext(uv);if(!e)throw Error(Pi(46));return e}let fv=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=il,..._}=e,v=Z_(),y=cv(),b=_l(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),j=v.useState(`transitionStatus`),M=Bf({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:v.useState(`adaptiveOrigin`)});Fh({store:v,domReference:x.useState(`domReferenceElement`),positionerElement:O,open:C});let N=E===!0&&w!==`trigger-hover`;Ih(C&&N,D===`touch`,O,T);let P=v.useStateSetter(`positionerElement`),F=Wf(e,{open:C,side:M.side,align:M.align,anchorHidden:M.anchorHidden,instant:k},{styles:M.positionerStyles,transitionStatus:j,props:_,refs:[t,P],hidden:!S,inert:!C});return/*#__PURE__*/ (0,A.jsxs)(uv.Provider,{value:M,children:[S&&N&&/*#__PURE__*/ (0,A.jsx)(Sp,{inert:Jf(!C),cutout:T}),/*#__PURE__*/ (0,A.jsx)(vl,{id:b,children:F})]})}),pv=/*#__PURE__*/ y.createContext(void 0);function mv(){let[e,t]=y.useState(0),n=$(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:y.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}function hv(){let e=y.useContext(pv);X(()=>e?.register(),[e])}let gv=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=Z_(),l=dv(),u=hh(!0)!=null,{context:d,hasClosePart:f}=mv(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);Ql({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),Ku(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?tu(c.context.popupRef):a,j=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,j);let M=c.useStateSetter(`popupElement`),N=Jc(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,M],props:[_,{id:T,role:`dialog`,...eu,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&yp.has(e.key)&&e.stopPropagation()}},Uf(g),s],stateAttributesMapping:Xa});return/*#__PURE__*/ (0,A.jsx)(Ol,{context:w,openInteractionType:m,modal:j,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:pa(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:/*#__PURE__*/ (0,A.jsx)(pv.Provider,{value:d,children:N})})}),_v=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Z_().useState(`open`),{arrowRef:s,side:c,align:l,arrowUncentered:u,arrowStyles:d}=dv();return Jc(`div`,e,{state:{open:o,side:c,align:l,uncentered:u},ref:[t,s],props:[{style:d,"aria-hidden":!0},a],stateAttributesMapping:Ya})}),vv=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Z_(),s=_f(a.id);return o.useSyncedValueWithCleanup(`titleElementId`,s),Jc(`h2`,e,{ref:t,props:[{id:s},a]})}),yv=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,{buttonRef:c,getButtonProps:l}=pp({disabled:a,focusableWhenDisabled:!1,native:o}),u=Z_();return hv(),Jc(`button`,e,{ref:[t,c],props:[{onClick(e){u.setOpen(!1,Q(vo,e.nativeEvent))}},s,l]})});function bv({open:e,onOpenChange:t,trigger:n,side:r=`bottom`,align:i=`start`,sideOffset:a=6,className:o,openOnHover:s,anchor:c,boundary:l,delay:u=0,id:d,focusOnOpen:f=!0,children:p,...m}){let h=l?.current??void 0;return/* @__PURE__ */ (0,A.jsxs)(rv,{open:e,onOpenChange:t,children:[/* @__PURE__ */ (0,A.jsx)(ov,{render:n,openOnHover:s,delay:u,closeDelay:150}),/* @__PURE__ */ (0,A.jsx)(lv,{children:/* @__PURE__ */ (0,A.jsx)(fv,{className:`ui-float`,side:r,align:i,sideOffset:a,anchor:c,collisionBoundary:h,collisionPadding:h?0:void 0,collisionAvoidance:h?{side:`flip`,align:`shift`}:void 0,children:/* @__PURE__ */ (0,A.jsx)(gv,{id:d,className:o,"aria-label":m[`aria-label`],initialFocus:f?void 0:!1,children:p})})})]})}En(),ir(),ti(Tn,rr);function xv({children:e,title:t,text:n,content:r,code:i,action:a,refHref:o,onRef:s,isRef:c,variant:l=`icon`,openOnFocus:u=!0,tabIndex:d,className:f}){let[p,m]=y.useState(!1),h=ee(),g=l===`inline`,_=y.useId(),v=y.useRef(null),[b,x]=y.useState(!1);y.useLayoutEffect(()=>{let e=v.current?.parentNode,t=!!e&&Array.from(e.childNodes).some(e=>e.nodeType===3&&!!e.textContent?.trim());x(t)},[e]);let S=y.useRef(null),C=e=>{if(e){let e=v.current?.closest(`.ui-card, .ui-split-a, .ui-split-b, .ui-shell-main, main`)??null;S.current=e&&e.getBoundingClientRect().width>=240?e:null}m(e)},T=t||(typeof e==`string`?e:``),E=e=>{u&&!h&&e.currentTarget.matches(`:focus-visible`)&&C(!0)},D=e=>{let t=e.relatedTarget;t&&(v.current?.contains(t)||document.getElementById(_)?.contains(t))||h||m(!1)},O=g?/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,ref:v,className:M(`ui-term`,`is-word`,p&&`is-open`,f),tabIndex:d,"aria-describedby":p&&!h?_:void 0,onFocus:E,onBlur:D,children:[e,/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:w(`,有說明`)})]}):/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,ref:v,className:M(`ui-term`,b&&`is-inline`,p&&`is-open`,f),children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:w(`說明`)+` `}),e,/* @__PURE__ */ (0,A.jsx)(Y,{name:`question`,size:14,className:`ui-term-q`})]}),k=(e,t)=>/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-term-head`,children:[/* @__PURE__ */ (0,A.jsx)(e,{className:`ui-term-title`,children:T}),/* @__PURE__ */ (0,A.jsx)(t,{className:`ui-dialog-close ui-term-close`,"aria-label":w(`關閉說明`),children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`})})]}),n?/* @__PURE__ */ (0,A.jsx)(Y_,{as:`div`,className:`ui-term-body`,text:n,refHref:o,onRef:s,isRef:c}):null,r?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-term-body`,children:r}):null,i?/* @__PURE__ */ (0,A.jsx)(`pre`,{className:`ui-term-code`,children:i}):null,a?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn ui-term-action`,onClick:()=>{m(!1),a.onClick?.()},children:a.label}):null]});return h?/* @__PURE__ */ (0,A.jsxs)(Vp,{open:p,onOpenChange:m,children:[/* @__PURE__ */ (0,A.jsx)(Jp,{render:O}),/* @__PURE__ */ (0,A.jsxs)(Cp,{children:[/* @__PURE__ */ (0,A.jsx)(cp,{className:`ui-term-backdrop`}),/* @__PURE__ */ (0,A.jsx)(xp,{className:`ui-term-sheet`,children:k(Up,gp)})]})]}):/* @__PURE__ */ (0,A.jsx)(bv,{open:p,onOpenChange:C,sideOffset:8,className:`ui-term-pop`,trigger:O,boundary:S,...g?{openOnHover:!0,delay:500,id:_,focusOnOpen:!1}:{},children:g?/* @__PURE__ */ (0,A.jsx)(`div`,{onBlur:D,children:k(vv,yv)}):k(vv,yv)})}let Sv=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),Cv=/^[\p{Script=Latin}\p{N}_]$/u;function wv(e){let t=(e??[]).filter(e=>e.term);if(!t.length)return null;let n=[...t].sort((e,t)=>t.term.length-e.term.length).map(e=>{let t=[...e.term],n=Cv.test(t[0])?`(?<![\\p{Script=Latin}\\p{N}_])`:``,r=Cv.test(t[t.length-1])?`(?![\\p{Script=Latin}\\p{N}_])`:``;return n+Sv(e.term)+r});return new RegExp(n.join(`|`),`gu`)}function Tv(e,t,n,r,i){let a=[];for(let o of e.matchAll(n)){let e=t.findIndex(e=>e.term===o[0]);if(!(e<0)){if(r===`first`){if(i.has(o[0]))continue;i.add(o[0])}a.push({from:o.index,to:o.index+o[0].length,i:e})}}return a}function Ev(e,t,n,r){return/* @__PURE__ */ (0,A.jsx)(xv,{variant:`inline`,title:e.title,text:e.text,action:e.action,...r,children:n??e.term},t)}function Dv(e,t,n,r,i=e=>e,a){let o=[],s=0;for(let c of t)c.from>s&&o.push(/* @__PURE__ */ (0,A.jsx)(y.Fragment,{children:i(e.slice(s,c.from))},r())),o.push(Ev(n[c.i],r(),e.slice(c.from,c.to),a)),s=c.to;return s<e.length&&o.push(/* @__PURE__ */ (0,A.jsx)(y.Fragment,{children:i(e.slice(s))},r())),o}let Ov={c:new Set(`auto break case char const continue default do double else enum extern float for goto if inline int long register restrict return short signed sizeof static struct switch typedef union unsigned void volatile while bool true false NULL nullptr class namespace template typename public private protected virtual new delete`.split(` `)),js:new Set(`async await break case catch class const continue default delete do else export extends false finally for from function if import in instanceof let new null of return static super switch this throw true try typeof undefined var void while yield interface type enum implements`.split(` `)),py:new Set(`and as assert async await break class continue def del elif else except False finally for from global if import in is lambda None nonlocal not or pass raise return True try while with yield`.split(` `)),sh:new Set(`if then else elif fi for while do done case esac in function return export local set unset echo exit`.split(` `))},kv={c:`c`,h:`c`,cc:`c`,cpp:`c`,hpp:`c`,cu:`c`,js:`js`,jsx:`js`,ts:`js`,tsx:`js`,mjs:`js`,py:`py`,sh:`sh`,bash:`sh`};function Av(e){let t=/\.([A-Za-z0-9]+)$/.exec(e||``);return t&&kv[t[1].toLowerCase()]||`plain`}let jv={c:`C 語言`,js:`JavaScript`,py:`Python`,sh:`Shell`},Mv=(e,t)=>{let n=Ov[t];if(!n)return e.map(e=>[[``,e]]);let r=t===`py`||t===`sh`,i=r?/(#.*$)|("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')|([A-Za-z_]\w*)|(\b\d[\w.]*)/g:/(\/\/.*$|\/\*.*?(?:\*\/|$))|("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`)|([A-Za-z_]\w*)|(\b\d[\w.]*)/g,a=!1;return e.map(e=>{let t=[],o=0;if(a){let n=e.indexOf(`*/`);if(n<0)return[[`is-comment`,e]];t.push([`is-comment`,e.slice(0,n+2)]),o=n+2,a=!1}i.lastIndex=o;let s;for(;s=i.exec(e);){s.index>o&&t.push([``,e.slice(o,s.index)]);let c=s[1]?`is-comment`:s[2]?`is-string`:s[3]?n.has(s[3])?`is-keyword`:/^[A-Z][A-Z0-9_]+$/.test(s[3])?`is-constant`:``:`is-constant`;s[1]&&!r&&s[1].startsWith(`/*`)&&!s[1].endsWith(`*/`)&&(a=!0),t.push([c,s[0]]),o=s.index+s[0].length,s[0].length||i.lastIndex++}return o<e.length&&t.push([``,e.slice(o)]),t.length?t:[[``,``]]})};rt(),Ir(),ti(nt,Fr);function Nv(e){let t=/^[ \t]*/.exec(e)?.[0]??``;if(!t||t.length===e.length)return``;let n=t.split(` `).length-1,r=t.length-n;return w(`,`)+(n&&r?w(`縮排 {a} 個 tab、{b} 格`,{a:n,b:r}):n?w(`縮排 {n} 個 tab`,{n}):w(`縮排 {n} 格`,{n:r}))}let Pv=/(->|::|==|!=|<=|>=|&&|\|\||\+\+|--|<<|>>|=>|\+=|-=|\*=|\/=)/,Fv=/([,.([{;])/,Iv=/(?<![\w./-])((?:\.{1,2}\/)?(?:[\w.-]+\/)+[\w.-]+\.[A-Za-z0-9]+(?::\d+(?:-\d+)?)?|[\w.-]+\.[A-Za-z0-9]+:\d+(?:-\d+)?)(?![\w/])/g;function Lv(e,t,n,r){let i=[],a=0;for(let o of e.matchAll(Iv)){let s=o[1],c=t&&t(s)||void 0;if(t?!c:!n)continue;o.index>a&&i.push(Rv(e.slice(a,o.index)));let l=n?e=>{c&&(e.metaKey||e.ctrlKey||e.shiftKey||e.button===1)||(e.preventDefault(),n(s,e))}:void 0;i.push(c?/* @__PURE__ */ (0,A.jsx)(`a`,{className:`ui-cv-ref`,href:c,onClick:l,tabIndex:r,children:s},o.index):/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-cv-ref`,onClick:l,tabIndex:r,children:s},o.index)),a=o.index+s.length}return i.length?(a<e.length&&i.push(Rv(e.slice(a))),i):Rv(e)}function Rv(e){if(!Pv.test(e)&&!Fv.test(e))return e;let t=[];return e.split(Pv).forEach((e,n)=>{e&&(n%2?t.push(/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-cv-op`,children:e},n),/* @__PURE__ */ (0,A.jsx)(`wbr`,{},n+`w`)):e.split(Fv).forEach((e,r)=>{e&&(t.push(e),r%2&&t.push(/* @__PURE__ */ (0,A.jsx)(`wbr`,{},n+`.`+r)))}))}),t}let zv=/[\p{L}\p{N}_$]/u;function Bv(e,t){let n=0;for(let r=1;r<t;r++){if(n>=e.length)return-1;n+=(e.codePointAt(n)??0)>65535?2:1}return n}function Vv(e,t){for(let n=e.indexOf(t);n>=0;n=e.indexOf(t,n+1)){let r=e[n-1]??``,i=e[n+t.length]??``;if(!zv.test(r)&&r!==`.`&&!zv.test(i))return n}return-1}function Hv(e,t,n){let r=/* @__PURE__ */ new Map;n?.forEach((n,i)=>{let a=e[n.line-t];if(a==null){G(!0,`CodeView`,`第 ${n.line} 行不在程式碼裡,連結「${n.text}」沒有加上。line 和 target 一樣從 start(${t})算起。`);return}let o=-1;if(n.col!=null){let e=Bv(a,n.col);e>=0&&a.startsWith(n.text,e)?o=e:G(!0,`CodeView`,`第 ${n.line} 行第 ${n.col} 欄不是「${n.text}」,連結沒有加上。col 從 1 開始、以字元計;位元組或 UTF-16 位置要先換算。`)}else o=Vv(a,n.text),G(o<0,`CodeView`,`第 ${n.line} 行找不到完整的「${n.text}」,連結沒有加上。text 要和程式碼一字不差(整個帶點的名稱),或給 col。`);if(o<0)return;let s={from:o,to:o+n.text.length,i},c=r.get(n.line)??[];c.some(e=>e.from<s.to&&s.from<e.to)?G(!0,`CodeView`,`第 ${n.line} 行的「${n.text}」和另一個連結重疊,沒有加上。同一行出現兩次的名稱,第二個要給 col。`):(c.push(s),r.set(n.line,c))});for(let e of r.values())e.sort((e,t)=>e.from-t.from);return r}function Uv(e){let t=typeof window>`u`?null:window.getSelection();if(!e||!t||t.isCollapsed||!t.rangeCount)return!1;let n=t.getRangeAt(0);return e.contains(n.startContainer)||e.contains(n.endContainer)}function Wv(e){let t=window.getSelection();if(!t||t.isCollapsed||!t.rangeCount)return null;let n=t.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return null;let r=n.cloneContents();r.querySelectorAll(`.ui-cv-num, .ui-visually-hidden`).forEach(e=>e.remove());let i=[...r.querySelectorAll(`[role="listitem"]`)];return i.length?i.map(e=>e.textContent??``).join(`
80
- `):r.textContent??``}function Gv(e){for(let t=e;t&&t!==document.body&&t!==document.documentElement;t=t.parentElement){let e=getComputedStyle(t).overflowY;if((e===`auto`||e===`scroll`||e===`overlay`)&&t.scrollHeight>t.clientHeight)return t}return null}function Kv(e,t,n){let r=Gv(n),i=r?(()=>{let e=r.getBoundingClientRect().top+r.clientTop;return{top:e,bottom:e+r.clientHeight}})():{top:0,bottom:window.innerHeight},a=e.getBoundingClientRect().top,o=t.getBoundingClientRect().bottom,s=0;o-a>i.bottom-i.top||a<i.top?s=a-i.top:o>i.bottom&&(s=o-i.bottom),s=Math.round(s),s&&(r?r.scrollTop+=s:window.scrollBy(0,s))}function qv(e,t,n,r,i){let a=/* @__PURE__ */ new Map,o=wv(r);if(!o||!r)return a;let s=/* @__PURE__ */ new Set;return e.forEach((e,c)=>{let l=t+c,u=n.get(l)??[],d=0;for(let[t,n]of e){if(t===`is-comment`||t===`is-string`){let e=[...n.matchAll(Iv)].map(e=>({from:d+e.index,to:d+e.index+e[0].length})),t=(t,n)=>![...u,...e].some(e=>e.from<n&&t<e.to),c=Tv(n,r,o,`all`,/* @__PURE__ */ new Set).map(e=>({...e,from:e.from+d,to:e.to+d})).filter(e=>t(e.from,e.to)).filter(e=>{if(i===`all`)return!0;let t=r[e.i].term;return!s.has(t)&&(s.add(t),!0)});c.length&&a.set(l,[...a.get(l)??[],...c])}d+=n.length}}),a}function Jv(e){return/* @__PURE__ */ (0,A.jsx)(bv,{open:e.open,onOpenChange:e.onOpenChange,trigger:e.trigger,side:`bottom`,align:`end`,className:`ui-popover ui-cv-keys`,"aria-label":w(`鍵盤操作`),children:/* @__PURE__ */ (0,A.jsxs)(`dl`,{className:`ui-cv-keylist`,children:[e.keys.map(e=>/* @__PURE__ */ (0,A.jsxs)(`div`,{children:[/* @__PURE__ */ (0,A.jsx)(`dt`,{children:/* @__PURE__ */ (0,A.jsx)(`kbd`,{children:e.label})}),/* @__PURE__ */ (0,A.jsx)(`dd`,{children:e.what})]},e.k)),/* @__PURE__ */ (0,A.jsxs)(`div`,{children:[/* @__PURE__ */ (0,A.jsx)(`dt`,{children:/* @__PURE__ */ (0,A.jsx)(`kbd`,{children:`?`})}),/* @__PURE__ */ (0,A.jsx)(`dd`,{children:w(`顯示或關閉這份說明`)})]})]})})}function Yv({code:e,start:t=1,target:n,context:r=2,file:i,fileHref:a,onFile:o,title:s,language:c,languageLabel:l,highlight:u=!0,tokenizer:d=Mv,refHref:f,onRef:p,links:m,onLink:h,preview:g,terms:_,termsMark:v=`first`,maxHeight:b,sections:x,copy:S,header:C=!0,lineNumbers:T=!0,onCopy:E,onCopyError:D,onLine:O,peek:k,className:j,ref:N}){let P=y.useMemo(()=>String(e||``).replace(/\n$/,``).split(`
81
- `),[e]),I=c||Av(i),L=y.useMemo(()=>u?d(P,I):P.map(e=>[[``,e]]),[P,I,u,d]),R=y.useMemo(()=>Hv(P,t,m),[P,t,m]),z=y.useMemo(()=>qv(L,t,R,_,v),[L,t,R,_,v]),B=R.size>0||z.size>0,[V,H]=y.useState(!1),U=y.useRef(!1);y.useEffect(()=>{if(!B)return;let e=e=>{(e.key===`Control`||e.key===`Meta`)&&H(e.type===`keydown`&&U.current)},t=()=>H(!1);return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,e),window.addEventListener(`blur`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,e),window.removeEventListener(`blur`,t)}},[B]);let[ne,W]=y.useState(null),re=y.useId(),ie=y.useRef(void 0),G=y.useRef(void 0);y.useEffect(()=>()=>{clearTimeout(ie.current),clearTimeout(G.current)},[]);let K=e=>{g&&(clearTimeout(G.current),clearTimeout(ie.current),ne?.el!==e&&(ie.current=setTimeout(()=>W({i:Number(e.dataset.link),el:e}),500)))},q=()=>{clearTimeout(ie.current),clearTimeout(G.current),G.current=setTimeout(()=>W(null),200)},ae=()=>clearTimeout(G.current),oe=e=>e instanceof Element?e.closest(`.ui-cv-name`):null,se=(e,t)=>{let n=m?.[Number(e.dataset.link)];n&&(clearTimeout(ie.current),W(null),h?h(n,t):n.href&&window.location.assign(n.href))},ce=e=>{let t=oe(e.target);if(!t)return;let n=m?.[Number(t.dataset.link)]?.href;if(e.shiftKey&&n)return;e.preventDefault();let r=e.nativeEvent.pointerType;(e.detail===0||r===`touch`||r===`pen`||e.ctrlKey||e.metaKey)&&se(t,e)},[le,J]=n==null?[null,null]:Array.isArray(n)?n:[n,n],ue=ee(),[de,fe]=y.useState(!1),[pe,me]=y.useState({code:e,ta:le,tb:J});(pe.code!==e||pe.ta!==le||pe.tb!==J)&&(me({code:e,ta:le,tb:J}),fe(!1));let he=le!=null&&J!=null&&P.length>J-le+1+r*2,ge=ue&&he&&!de,_e=ge?Math.max(0,le-t-r):0,ve=ge?Math.min(P.length,J-t+r+1):P.length,ye=y.useRef(null);y.useImperativeHandle(N,()=>({focusTarget:()=>{Uv(ye.current)||ye.current?.querySelector(`.is-target`)?.focus()}})),y.useEffect(()=>{let e=ye.current,t=e?.querySelector(`.is-target`);e&&t&&e.scrollHeight>e.clientHeight&&!Uv(e)&&(e.scrollTop+=t.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientHeight/2+t.offsetHeight/2)},[le,e]);let[be,xe]=k==null?[NaN,NaN]:typeof k==`number`?[k,k]:[Math.min(k.from,k.to),Math.max(k.from,k.to)];y.useEffect(()=>{if(Number.isNaN(be))return;let e=ye.current;if(!e)return;let t=[...e.querySelectorAll(`[data-n]`)].filter(e=>{let t=Number(e.dataset.n);return t>=be&&t<=xe});t.length&&Kv(t[0],t[t.length-1],e)},[be,xe]);let Se=String(t+P.length-1).length,Ce=(e,t,n)=>!n&&(f||p)&&(e===`is-comment`||e===`is-string`)?Lv(t,f,p,B?-1:void 0):Rv(t),we=(e,t,n,r,i=0,a)=>{let o=!r&&_&&a?a.filter(e=>e.from>=i&&e.to<=i+t.length):[],s=0,c=o.length&&_?Dv(t,o.map(e=>({...e,from:e.from-i,to:e.to-i})),_,()=>n+`t`+s++,t=>Ce(e,t,!1),{className:`ui-cv-term`,tabIndex:-1,openOnFocus:!1}):Ce(e,t,r);return e?/* @__PURE__ */ (0,A.jsx)(`span`,{className:e,children:c},n):/* @__PURE__ */ (0,A.jsx)(y.Fragment,{children:c},n)},Te=(e,t)=>{let n=m?.[e.i];return n?/* @__PURE__ */ (0,A.jsx)(`a`,{className:`ui-cv-name`,href:n.href,role:n.href?void 0:`link`,tabIndex:-1,draggable:!1,"data-link":e.i,"aria-label":n.label,"aria-describedby":ne?.i===e.i?re:void 0,title:g?void 0:n.label,children:t},`n`+e.i):null},Ee=(e,t,n)=>{if(!t){let t=0;return e.map(([e,r],i)=>{let a=we(e,r,String(i),!1,t,n);return t+=r.length,a})}let r=[],i=[],a=null,o=()=>{a&&r.push(Te(a,i)),a=null,i=[]},s=0,c=0;return e.forEach(([e,l],u)=>{let d=0;for(;d<l.length;){let f=s+d;for(;c<t.length&&t[c].to<=f;)c++;let p=t[c],m=p&&p.from<=f?p:null,h=Math.min(s+l.length,m?m.to:p?p.from:1/0),g=u+`.`+d;m?(a!==m&&(o(),a=m),i.push(we(e,l.slice(d,h-s),g,!0))):(o(),r.push(we(e,l.slice(d,h-s),g,!1,f,n))),d=h-s}s+=l.length}),o(),r},De=[];for(let e=_e;e<ve;e++){let n=t+e,r=le!=null&&J!=null&&n>=le&&n<=J;De.push(/* @__PURE__ */ (0,A.jsxs)(`div`,{role:`listitem`,className:M(`ui-cv-line`,r&&`is-target`,n>=be&&n<=xe&&`is-peek`),"data-n":n,"aria-current":r&&n===le?`location`:void 0,tabIndex:r&&n===le?-1:void 0,children:[T?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-cv-num`,style:{width:`calc(${Se}ch + 28px)`},"aria-hidden":`true`,children:n}):null,/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-cv-text`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden ui-cv-sr`,children:w(`第 {n} 行`,{n})+Nv(P[e])+w(`:`)}),Ee(L[e],R.get(n),z.get(n))]})]},e))}let Oe=[...B?[{k:`ArrowUp ArrowDown`,label:`↑↓`,what:w(`上一行/下一行`)},{k:`ArrowLeft ArrowRight`,label:`←→`,what:w(z.size?R.size?`上一個/下一個連結或名詞`:`上一個/下一個名詞`:`上一個/下一個連結`)},{k:`Enter`,label:`Enter`,what:w(`開啟`)},{k:`Escape`,label:`Esc`,what:w(`回到這一行`)}]:[],{k:`Home`,label:`Home`,what:w(`第一行`)},{k:`End`,label:`End`,what:w(`最後一行`)},{k:`PageUp`,label:`PgUp`,what:w(`上 20 行`)},{k:`PageDown`,label:`PgDn`,what:w(`下 20 行`)},...x?.length?[{k:`[`,label:`[`,what:w(`上一段`)},{k:`]`,label:`]`,what:w(`下一段`)}]:[]],ke=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;if(e.key===`?`){e.preventDefault(),Ie.current=!0,Fe(e=>!e);return}let t=e.currentTarget,n=[...t.querySelectorAll(`[role="listitem"]`)];if(!n.length)return;let r=e=>Number(e.dataset.n),i=document.activeElement instanceof HTMLElement?document.activeElement:null,a=i&&i!==t?i.closest(`[role="listitem"]`):null,o=a?n.indexOf(a):-1,s=o<0?-1:o,c=e=>{e&&(e.tabIndex=-1,e.focus(),O?.(r(e),`key`))};if(O&&!B&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){e.preventDefault(),c(s<0?n.find(e=>e.classList.contains(`is-target`))??n[0]:n[Math.max(0,Math.min(n.length-1,s+(e.key===`ArrowDown`?1:-1)))]);return}if(B){let o=[...t.querySelectorAll(`.ui-cv-name, .ui-cv-ref, .ui-cv-term`)],l=i?o.indexOf(i):-1;if(e.key===`Escape`){if(i?.classList.contains(`ui-cv-term`)&&i.getAttribute(`aria-expanded`)===`true`)return;if(ne)W(null);else if(l>=0)c(a??void 0);else if(a)t.focus();else return;e.preventDefault();return}if(e.key===`Enter`&&i&&l>=0&&i.classList.contains(`ui-cv-name`)&&!i.hasAttribute(`href`)){e.preventDefault(),se(i,e);return}if(e.key===`ArrowUp`||e.key===`ArrowDown`){e.preventDefault(),c(s<0?n.find(e=>e.classList.contains(`is-target`))??n[0]:n[Math.max(0,Math.min(n.length-1,s+(e.key===`ArrowDown`?1:-1)))]);return}if(e.key===`ArrowLeft`||e.key===`ArrowRight`){e.preventDefault();let t=e.key===`ArrowRight`,i;if(l>=0)i=o[l+(t?1:-1)];else{let e=a?r(a):le??r(n[0]),s=e=>Number(e.closest(`[role="listitem"]`)?.dataset.n);i=t?o.find(t=>s(t)>=e):o.filter(t=>s(t)<=e).pop()}i?.focus();return}}let l=-1,u=``;if(e.key===`Home`)l=0;else if(e.key===`End`)l=n.length-1;else if(e.key===`PageDown`)l=Math.min(n.length-1,Math.max(0,s)+20);else if(e.key===`PageUp`)l=Math.max(0,s-20);else if((e.key===`[`||e.key===`]`)&&x?.length){let t=s<0?e.key===`]`?-1/0:1/0:r(n[s]),i=[...x].sort((e,t)=>e.line-t.line),a=e.key===`]`?i.find(e=>e.line>t):[...i].reverse().find(e=>e.line<t);a&&(l=n.findIndex(e=>r(e)>=a.line),u=a.label)}else return;e.preventDefault();let d=n[l];d&&(d.tabIndex=-1,d.focus(),O?.(r(d),`key`),u&&bi(w(`{name},第 {n} 行`,{name:u,n:r(d)})))},Ae=e=>{if(!O)return;let t=e.target instanceof Element?e.target:null;if(!t)return;let n=e.nativeEvent.pointerType;if(t.closest(`.ui-cv-name`)&&(e.detail===0||n===`touch`||n===`pen`||e.ctrlKey||e.metaKey)||t.closest(`a:not(.ui-cv-name), button:not(.ui-cv-name)`)||Uv(e.currentTarget))return;let r=t.closest(`[role="listitem"]`);r&&O(Number(r.dataset.n),`click`)},je=e=>{let t=Wv(e.currentTarget);t!=null&&(e.preventDefault(),e.clipboardData.setData(`text/plain`,t))},[Me,Ne]=y.useState(!1),[Pe,Fe]=y.useState(!1),Ie=y.useRef(!1),Le=y.useRef(void 0);y.useEffect(()=>()=>clearTimeout(Le.current),[]);let Re=()=>{te(e).then(()=>{Ne(!0),bi(w(`已複製`)),clearTimeout(Le.current),Le.current=setTimeout(()=>Ne(!1),2e3),E?.(e)},()=>D?.())},ze=l!==!1&&I!==`plain`?/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-cv-lang`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:w(`程式語言`)+w(`:`)}),w(l||jv[I]||I)]}):null,Be=S?/* @__PURE__ */ (0,A.jsx)(np,{className:M(`ui-cv-copy`,Me&&`is-copied`),variant:C===`float`?`quiet`:void 0,label:w(Me?`已複製`:`複製程式碼`),icon:Me?pi:`copy`,onClick:Re}):null,Ve=e=>{Fe(e),!e&&Ie.current&&(Ie.current=!1,requestAnimationFrame(()=>ye.current?.focus()))},He=e=>/* @__PURE__ */ (0,A.jsx)(Jv,{open:Pe,onOpenChange:Ve,trigger:e,keys:Oe}),Ue=He(/* @__PURE__ */ (0,A.jsx)(np,{variant:`quiet`,icon:`keyboard`,label:w(`鍵盤操作`),onClick:()=>Ie.current=!1})),We=C===`float`?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-cv-tools`,children:[ze,Be,Ue]}):C===!1?He(/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-cv-keyanchor`,"aria-hidden":`true`})):i||s||S?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-cv-head`,children:[i?a||o?/* @__PURE__ */ (0,A.jsx)(K_,{href:a,onClick:o,className:`ui-cv-file`,children:i}):/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-cv-file`,children:i}):s?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-cv-title`,children:s}):null,ze,Be,Ue]}):He(/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-cv-keyanchor`,"aria-hidden":`true`}));return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-cv`,!T&&`no-nums`,C===`float`&&`is-float`,j),role:`region`,"aria-label":i||s||w(`原始碼`),children:[We,/* @__PURE__ */ (0,A.jsx)(`pre`,{ref:ye,style:b?{maxHeight:b}:void 0,tabIndex:0,"aria-label":w(`程式碼`),"aria-keyshortcuts":[...Oe.map(e=>e.k),`?`].join(` `),onKeyDown:ke,onCopy:je,onClick:B?void 0:Ae,...B?{onClick:e=>{ce(e),Ae(e)},onPointerEnter:()=>U.current=!0,onPointerLeave:()=>{U.current=!1,H(!1)},onPointerMove:e=>{let t=e.ctrlKey||e.metaKey;t!==V&&H(t)},onPointerOver:e=>{let t=oe(e.target);t&&e.pointerType===`mouse`&&K(t)},onPointerOut:e=>{let t=oe(e.target);t&&!t.contains(e.relatedTarget)&&q()},onFocus:e=>{let t=oe(e.target);t&&t.matches(`:focus-visible`)&&K(t)},onBlur:e=>{oe(e.target)&&q()}}:null,className:M(`ui-cv-body`,V&&`is-armed`),children:/* @__PURE__ */ (0,A.jsx)(`code`,{role:`list`,children:De})}),g&&ne&&m?.[ne.i]?/* @__PURE__ */ (0,A.jsx)(R_,{open:!0,onOpenChange:e=>e?void 0:W(null),children:/* @__PURE__ */ (0,A.jsx)(V_,{children:/* @__PURE__ */ (0,A.jsx)(W_,{anchor:ne.el,side:`bottom`,align:`start`,sideOffset:6,className:`ui-float`,children:/* @__PURE__ */ (0,A.jsx)(G_,{id:re,className:`ui-popover ui-cv-preview`,onPointerEnter:ae,onPointerLeave:q,children:g(m[ne.i])})})})}):null,ue&&he?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn ui-cv-more`,onClick:()=>fe(!de),children:/* @__PURE__ */ (0,A.jsx)(`span`,{children:de?w(`只顯示第 {n} 行前後`,{n:le}):F(w(`顯示全部 {n} 行`,{n:``}),[P.length])})}):null]})}Er(),xt(),Sr(),Ct(),Ft(),cn(),ti(Tr,bt,xr,St,Pt,sn);let Xv={頁面:`file-text`,設定:`gear`,指令:`command`,檔案:`file-code`};function Zv(e,t){let n=e.label.toLowerCase().indexOf(t);return n===0?[0,0]:n>0?[1,n]:[e.detail,e.kind,...e.keywords??[]].join(` `).toLowerCase().includes(t)?[2,-1]:null}function Qv(e){let{open:t,onOpenChange:n,items:r,onSelect:i,placeholder:a,recent:o,recentLabel:s,emptyText:c,noResultsText:l,kinds:u,filter:d=!0,onQueryChange:f,loading:p,total:m,limit:h=50,hotkey:g=!0,defaultQuery:_=``,label:v}=e,[b,x]=y.useState(_),[S,C]=y.useState(0);Im(t);let[T,E]=y.useState(t);t!==T&&(E(t),t&&(x(_),C(0)));let D=y.useRef(null),O=y.useId(),k=y.useRef(n),j=y.useRef(f);y.useLayoutEffect(()=>{k.current=n,j.current=f}),y.useEffect(()=>{t&&j.current?.(_)},[t,_]),y.useEffect(()=>{if(!g)return;let e=e=>{(e.ctrlKey||e.metaKey)&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`k`&&(e.preventDefault(),k.current(!t))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[g,t]);let N=b.trim().toLowerCase(),P=(d===!1?r.map(e=>({it:e,at:-1})):N?r.map((e,t)=>{let n=Zv(e,N);return n?{it:e,rank:n[0],at:n[1],i:t}:null}).filter(e=>e!==null).sort((e,t)=>e.rank-t.rank||e.i-t.i):(o??[]).map(e=>({it:e,at:-1}))).slice(0,h),F=Math.min(S,Math.max(0,P.length-1));y.useEffect(()=>{D.current?.querySelector(`.is-active`)?.scrollIntoView?.({block:`nearest`})},[F,t]);let I=e=>{n(!1),i?.(e)},L=e=>{if(!(e.nativeEvent.isComposing||e.keyCode===229)){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;C(P.length?(F+t+P.length)%P.length:0)}else e.key===`Enter`&&(e.preventDefault(),P[F]&&I(P[F].it))}},R=(e,t)=>{let n=e.label;return/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-pal-label`,e.code&&`is-code`),children:t>=0&&N?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[n.slice(0,t),/* @__PURE__ */ (0,A.jsx)(`mark`,{className:`ui-pal-hit`,children:n.slice(t,t+N.length)}),n.slice(t+N.length)]}):n})},z=N?(e=>typeof l==`function`?l(e):(l??w(`找不到符合「{q}」的結果`)).replace(`{q}`,e))(b.trim()):c||w(`輸入名稱開始搜尋`),B=m!=null&&m>P.length?m-P.length:0,V=B?w(`顯示 {n} 筆,另有 {m} 筆,請輸入更長的字`,{n:P.length,m:B}):w(`共 {n} 筆`,{n:P.length}),H=t&&N?p?w(`搜尋中`):P.length?B?V:w(`找到 {n} 筆結果`,{n:P.length}):z:``;return y.useEffect(()=>{if(!H)return;let e=setTimeout(()=>bi(H),400);return()=>clearTimeout(e)},[H,N,p]),/* @__PURE__ */ (0,A.jsx)(Vp,{open:t,onOpenChange:n,children:/* @__PURE__ */ (0,A.jsxs)(Cp,{children:[/* @__PURE__ */ (0,A.jsx)(cp,{className:`ui-pal-backdrop`}),/* @__PURE__ */ (0,A.jsxs)(xp,{className:`ui-pal`,"aria-label":v||w(`搜尋`),children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-pal-head`,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`magnifying-glass`,className:`ui-pal-icon`}),/* @__PURE__ */ (0,A.jsx)(`input`,{className:`ui-pal-input`,type:`text`,value:b,placeholder:a||w(`搜尋`),role:`combobox`,"aria-expanded":P.length>0,"aria-controls":P.length?O:void 0,"aria-autocomplete":`list`,"aria-activedescendant":P[F]?`${O}-${F}`:void 0,autoComplete:`off`,spellCheck:!1,enterKeyHint:`go`,onChange:e=>{x(e.target.value),C(0),f?.(e.target.value)},onKeyDown:L}),/* @__PURE__ */ (0,A.jsx)(gp,{className:`ui-pal-cancel`,children:w(`取消`)})]}),!N&&P.length&&o?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-pal-group`,children:s||w(`最近開啟`)}):null,P.length?/* @__PURE__ */ (0,A.jsx)(`ul`,{ref:D,id:O,className:`ui-pal-list`,role:`listbox`,"aria-label":w(`搜尋結果`),children:P.map(({it:e,at:t},n)=>/* @__PURE__ */ (0,A.jsxs)(`li`,{id:`${O}-${n}`,role:`option`,"aria-selected":n===F,className:M(`ui-pal-item`,n===F&&`is-active`),onMouseMove:()=>F!==n&&C(n),onMouseDown:e=>e.preventDefault(),onClick:()=>I(e),children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-pal-kind`,title:e.kind,children:/* @__PURE__ */ (0,A.jsx)(fi,{icon:e.icon??(e.kind?u?.[e.kind]??Xv[e.kind]:void 0)??`file`,size:16})}),/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-pal-text`,children:[/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-pal-line`,children:[e.kind?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:e.kind+` `}):null,R(e,t)]}),e.detail?/* @__PURE__ */ (0,A.jsx)(Y_,{className:`ui-pal-detail`,text:e.detail}):null]})]},e.id??n))}):/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-pal-empty`,children:p?w(`搜尋中`):z}),p&&P.length?/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-pal-loading`,children:w(`搜尋中`)}):null,N&&!p&&P.length?/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-pal-count`,"aria-hidden":`true`,children:V}):null,/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-pal-keys`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsxs)(`span`,{children:[/* @__PURE__ */ (0,A.jsx)(`kbd`,{children:`↑`}),/* @__PURE__ */ (0,A.jsx)(`kbd`,{children:`↓`}),w(`選擇`)]}),/* @__PURE__ */ (0,A.jsxs)(`span`,{children:[/* @__PURE__ */ (0,A.jsx)(`kbd`,{children:`Enter`}),w(`打開`)]}),/* @__PURE__ */ (0,A.jsxs)(`span`,{children:[/* @__PURE__ */ (0,A.jsx)(`kbd`,{children:`Esc`}),w(`關閉`)]})]})]})]})})}function $v({title:e,description:t,actionLabel:n,onAction:r,confirm:i,className:a}){let o=n||w(`刪除`);return/* @__PURE__ */ (0,A.jsxs)(`section`,{className:M(`ui-danger`,a),children:[/* @__PURE__ */ (0,A.jsx)(`h2`,{className:`ui-danger-title`,children:e||w(`危險操作`)}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-danger-row`,children:[/* @__PURE__ */ (0,A.jsx)(`p`,{children:t}),/* @__PURE__ */ (0,A.jsx)(Xp,{variant:`danger`,confirm:i??{title:w(`{label}?`,{label:o})},onClick:r,children:o})]})]})}cn(),ir(),ti(sn,rr);function ey({value:e,onChange:t,className:n,label:r,...i}){let a=y.useRef(null);return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-searchfield`,n),children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`magnifying-glass`,size:16,className:`ui-searchfield-icon`}),/* @__PURE__ */ (0,A.jsx)(`input`,{ref:a,type:`search`,"aria-label":r||w(`搜尋`),...i,className:`ui-input`,value:e,onChange:e=>t(e.target.value)}),e?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-searchfield-clear`,"aria-label":w(`清除搜尋`),onClick:()=>{t(``),a.current?.focus()},children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`,size:12})}):null]})}function ty({items:e,value:t,onChange:n,label:r,unit:i,className:a}){let o=y.useRef([]),s=y.useRef(null),[c,l]=y.useState(null),[u,d]=y.useState(!0),[f,p]=gi(),[m,h]=y.useState({left:!1,right:!1}),g=y.useCallback(()=>{let e=s.current;if(!e)return;let t=e.scrollLeft>1,n=o.current.filter(Boolean).pop(),r=n?n.offsetLeft+n.offsetWidth:e.scrollWidth,i=e.scrollLeft+e.clientWidth<r-1;h(e=>e.left===t&&e.right===i?e:{left:t,right:i})},[]);Lm(s,()=>o.current[Math.max(0,e.findIndex(e=>e.id===t))]),G(e.some(e=>e.count!=null&&!(e.unit||i)),`Tabs`,`a count has no unit, so it reads as a bare number. Pass unit, e.g. unit: '筆', on Tabs or on the item.`);let _=Math.max(0,e.findIndex(e=>e.id===t));y.useLayoutEffect(()=>{let e=o.current[_],t=s.current;if(!e||!t)return;let n=()=>{l({left:e.offsetLeft,right:t.clientWidth-e.offsetLeft-e.offsetWidth}),g()};n(),e.offsetLeft<t.scrollLeft?t.scrollLeft=e.offsetLeft-4:e.offsetLeft+e.offsetWidth>t.scrollLeft+t.clientWidth&&(t.scrollLeft=e.offsetLeft+e.offsetWidth-t.clientWidth+4);let r=U(n);r?.observe(t);for(let e of o.current)e&&r?.observe(e);return()=>r?.disconnect()},[_,e.length,g]);let v=t=>{t!==_&&e[t]&&(d(t>_),p(),n?.(e[t].id),bi(e[t].label+(e[t].count==null?``:` `+a_.number(e[t].count??0)+(e[t].unit||i?` `+T(e[t].unit||i,e[t].count??0):``))))};return/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:s,className:M(`ui-tabs`,m.left&&`has-more-left`,m.right&&`has-more-right`,a),role:`tablist`,"aria-label":r,onScroll:g,children:[c?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tabs-ind`,"aria-hidden":`true`,style:{left:c.left,right:c.right,transform:f?`scaleY(.82)`:`none`,transition:hi(`left`,`right`,u)}}):null,e.map((t,n)=>/* @__PURE__ */ (0,A.jsxs)(`button`,{ref:e=>{o.current[n]=e},type:`button`,role:`tab`,"aria-selected":n===_,tabIndex:n===_?0:-1,className:M(`ui-tab`,n===_&&`is-selected`),onClick:()=>v(n),onKeyDown:t=>{if(W(t))return;let r=t.key===`ArrowRight`?(n+1)%e.length:t.key===`ArrowLeft`?(n-1+e.length)%e.length:-1;r<0||(t.preventDefault(),o.current[r]?.focus(),v(r))},children:[t.label,t.count==null?null:` `,t.count==null?null:/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-tab-count`,children:[a_.number(t.count),t.unit||i?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[` `,/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-unit`,children:T(t.unit||i,t.count)})]}):null]})]},t.id))]})}J(),ti(le);function ny(){let e=y.useRef(null),[t,n]=y.useState(!1),[r,i]=y.useState(!1),[a,o]=y.useState(!1),s=y.useCallback(()=>{let t=e.current;if(!t)return;let r=t.scrollWidth>t.clientWidth+1;o(r),n(r&&t.scrollLeft+t.clientWidth<t.scrollWidth-1)},[]);return y.useLayoutEffect(()=>{let t=e.current;if(!t)return;s();let n=U(s);n?.observe(t),t.firstElementChild&&n?.observe(t.firstElementChild);let r=0,i=()=>{cancelAnimationFrame(r),r=requestAnimationFrame(s)},a=new MutationObserver(i);return a.observe(t,{childList:!0,subtree:!0,characterData:!0}),document.fonts?.ready.then(i).catch(()=>{}),()=>{n?.disconnect(),a.disconnect(),cancelAnimationFrame(r)}},[s]),{ref:e,more:t,overflows:a,scrolled:r,onScroll:y.useCallback(()=>{let t=e.current;t&&t.scrollLeft>0&&i(!0),s()},[s]),measure:s}}function ry({show:e,done:t}){let n=H(`(pointer: coarse)`);return e?/* @__PURE__ */ (0,A.jsxs)(`span`,{className:M(`ui-scroll-hint`,t&&`is-done`),"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`arrow-right`,size:14}),w(n?`左右滑動`:`向右捲動`)]}):null}rt(),Te(),ti(nt,we);function iy(e){let[t,n]=y.useState(!1),r=y.useRef(null),i=e.min??48,a=t=>e.onWidth(Math.max(i,Math.round(t))),o=t=>{n(t),e.onDragging?.(t)};return/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-col-resize`,t&&`is-dragging`),role:`separator`,"aria-orientation":`vertical`,"aria-label":w(`調整「{name}」欄寬`,{name:e.name}),"aria-valuenow":Math.round(e.width),"aria-valuemin":i,tabIndex:0,onClick:e=>e.stopPropagation(),onPointerDown:t=>{t.button===0&&(t.preventDefault(),t.stopPropagation(),t.currentTarget.setPointerCapture?.(t.pointerId),r.current={x:t.clientX,w:e.start()},o(!0))},onPointerMove:e=>{r.current&&a(r.current.w+e.clientX-r.current.x)},onPointerUp:()=>{r.current=null,o(!1)},onPointerCancel:()=>{r.current=null,o(!1)},onDoubleClick:t=>{t.stopPropagation(),e.onReset()},onKeyDown:t=>{t.altKey||t.metaKey||t.ctrlKey||(t.key===`ArrowLeft`||t.key===`ArrowRight`?(t.preventDefault(),t.stopPropagation(),a(e.start()+(t.key===`ArrowRight`?16:-16))):t.key===`Enter`&&(t.preventDefault(),t.stopPropagation(),e.onReset()))}})}function ay({onClick:e,inToolbar:t}){return/* @__PURE__ */ (0,A.jsx)(np,{className:t?`ui-dt-zoombtn`:`ui-table-zoom`,icon:`corners-out`,label:w(`放大表格`),onClick:e})}function oy(e){return e.open?/* @__PURE__ */ (0,A.jsx)(Zp,{open:!0,onClose:e.onClose,title:e.title||w(`表格`),className:`ui-table-dialog`,children:/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-table-dialog-body`,onClick:t=>{if(t.metaKey||t.ctrlKey||t.shiftKey||t.button!==0)return;let n=t.target.closest(`a[href], [role="link"], .ui-code.is-link, .ui-md-link`);n&&t.currentTarget.contains(n)&&e.onClose()},children:e.children})}):null}function sy(e,t){let n=e=>e.replace(/\r?\n/g,` `).replace(/\|/g,`\\|`).trim();return[`| ${e.map(n).join(` | `)} |`,`|${e.map(()=>`---`).join(`|`)}|`,...t.map(e=>`| ${e.map(n).join(` | `)} |`)].join(`
82
- `)}let cy=(e,t)=>e[t];function ly(e,t){if(t==null||t===``)return`—`;let n=()=>t instanceof Date?t:new Date(t);if(e.format===`money`)return a_.money(Number(t),{currency:e.currency});if(e.format===`date`)return a_.date(n());if(e.format===`datetime`)return a_.dateTime(n());if(e.format===`relative`)return a_.relative(n());if(e.format===`duration`)return a_.duration(Number(t));let r=e.format===`percent`?a_.number(Number(t),e.decimals??`percent`):e.numeric&&typeof t==`number`?a_.number(t,e.decimals??(e.unit===`GB`||e.unit===`MB`?`size`:0)):String(t);return e.unit?`${r} ${e.unit}`:r}let uy=[`date`,`datetime`,`relative`],dy=e=>uy.includes(e.format??``);function fy(e){if(e==null||e===``)return null;let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?null:t}function py(e,t){return e.map(e=>{let n=e.options;if((e.type??`list`)===`list`&&!n){let r=/* @__PURE__ */ new Set;n=[];for(let i of t){let t=cy(i,e.key);t!=null&&!r.has(String(t))&&(r.add(String(t)),n.push({value:String(t),label:String(t)}))}}return{...e,type:e.type??`list`,multiple:e.multiple??!0,options:n??[]}})}let my=e=>!Array.isArray(e);function hy(e){return e?my(e)?e.min!==``&&e.min!=null||e.max!==``&&e.max!=null:e.length>0:!1}function gy(e,t,n){if(!n||!hy(n))return!0;if(e.match)return e.match(t,n);let r=cy(t,e.key);if(my(n)){let t=e.scale||1,i=parseFloat(n.min),a=parseFloat(n.max),o=Number(r);return!(!Number.isNaN(i)&&o<i*t)&&!(!Number.isNaN(a)&&o>a*t)}return n.includes(String(r))}function _y(e,t,n,r,i){let a=r.toLowerCase();return t.some(t=>{if(i&&!i.includes(t.key))return!1;let r=cy(e,t.key),o=t.searchText?t.searchText(e):t.render?``:ly(t,r),s=n.find(e=>e.key===t.key)?.options.find(e=>e.value===String(r));return s&&(o+=` `+s.label),!o&&t.render&&(o=r==null?``:String(r)),t.secondary&&(o+=` `+re(t.secondary(e))),o.toLowerCase().includes(a)})}let vy=(e,t)=>(e?e+`.`:``)+t;function yy(e,t){let n={},r=new URLSearchParams(location.search);for(let i of t)if(i.type===`range`){let t=r.get(vy(e,i.key+`_min`)),a=r.get(vy(e,i.key+`_max`));(t||a)&&(n[i.key]={min:t||``,max:a||``})}else{let t=r.get(vy(e,i.key));t&&(n[i.key]=t.split(`,`))}return{q:r.get(vy(e,`q`))||``,values:n}}function by(e,t,n,r){let i=new URLSearchParams(location.search),a=(t,n)=>n?i.set(vy(e,t),n):i.delete(vy(e,t));a(`q`,r);for(let e of t){let t=n[e.key];e.type===`range`?(a(e.key+`_min`,t&&my(t)?t.min:void 0),a(e.key+`_max`,t&&my(t)?t.max:void 0)):a(e.key,t&&!my(t)&&t.length?t.join(`,`):void 0)}let o=i.toString();history.replaceState(history.state,``,location.pathname+(o?`?`+o:``)+location.hash)}function xy(e){let t=new URLSearchParams(location.search).get(vy(e,`sort`));return t==null?null:t.split(`,`).filter(Boolean).map(e=>e.startsWith(`-`)?{key:e.slice(1),dir:`desc`}:{key:e,dir:`asc`})}function Sy(e,t,n){let r=new URLSearchParams(location.search),i=e=>e.map(e=>(e.dir===`desc`?`-`:``)+e.key).join(`,`);i(t)===i(n)?r.delete(vy(e,`sort`)):r.set(vy(e,`sort`),i(t));let a=r.toString();history.replaceState(history.state,``,location.pathname+(a?`?`+a:``)+location.hash)}pe(),Fe(),cr(),rt(),Te(),lt(),jt(),ir(),ti(fe,Pe,sr,nt,we,ct,At,rr);function Cy(e,t){if(!t||typeof e!=`string`)return e;let n=e.toLowerCase().indexOf(t.toLowerCase());return n<0?e:/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[e.slice(0,n),/* @__PURE__ */ (0,A.jsx)(`mark`,{className:`ui-mark`,children:e.slice(n,n+t.length)}),e.slice(n+t.length)]})}function wy({columns:e,onCopy:t,onZoom:n}){if(!e&&!t&&!n)return null;let r=w(`更多表格操作`);return/* @__PURE__ */ (0,A.jsxs)(ig,{children:[/* @__PURE__ */ (0,A.jsx)(Zf,{label:r,describe:!1,children:/* @__PURE__ */ (0,A.jsx)(mg,{className:M(`ui-iconbtn`,`is-quiet`,`ui-menu-trigger`,`ui-dt-menubtn`),"aria-label":r,children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`dots-three`,size:20})})}),/* @__PURE__ */ (0,A.jsx)(Dh,{children:/* @__PURE__ */ (0,A.jsx)(Lh,{className:`ui-float`,side:`bottom`,align:`end`,sideOffset:4,children:/* @__PURE__ */ (0,A.jsxs)(wh,{className:`ui-menu ui-dt-moremenu`,children:[e?/* @__PURE__ */ (0,A.jsxs)(og,{children:[/* @__PURE__ */ (0,A.jsxs)(xg,{className:`ui-menu-item`,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`columns`,size:16}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-menu-label`,children:w(`欄位`)}),/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-right`,size:16,className:`ui-dt-subcaret`})]}),/* @__PURE__ */ (0,A.jsx)(Dh,{children:/* @__PURE__ */ (0,A.jsx)(Lh,{className:`ui-float`,side:`left`,align:`start`,sideOffset:4,alignOffset:-6,children:/* @__PURE__ */ (0,A.jsxs)(wh,{className:`ui-menu ui-dt-colmenu`,"aria-label":w(`顯示的欄位`),children:[/* @__PURE__ */ (0,A.jsxs)(uh,{children:[/* @__PURE__ */ (0,A.jsx)(dh,{className:`ui-noti-group`,children:w(`顯示的欄位`)}),e.cols.map((t,n)=>{let r=n===0||!e.hidden[t.key];return/* @__PURE__ */ (0,A.jsxs)(oh,{checked:r,disabled:n===0,closeOnClick:!1,className:`ui-menu-item`,onCheckedChange:()=>e.onToggle(t.key),children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-check-box`,r&&`is-on`),"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(E_,{v:r})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-menu-label`,children:t.label})]},t.key)})]}),/* @__PURE__ */ (0,A.jsx)(_g,{className:`ui-menu-sep`}),/* @__PURE__ */ (0,A.jsxs)(ph,{className:`ui-menu-item`,closeOnClick:!1,onClick:e.onReset,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`arrow-u-up-left`,size:16}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-menu-label`,children:w(`還原預設`)})]})]})})})]}):null,t?/* @__PURE__ */ (0,A.jsxs)(ph,{className:`ui-menu-item`,onClick:t,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`copy`,size:16}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-menu-label`,children:w(`複製成 Markdown`)})]}):null,n?/* @__PURE__ */ (0,A.jsxs)(ph,{className:`ui-menu-item`,onClick:n,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`corners-out`,size:16}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-menu-label`,children:w(`放大表格`)})]}):null]})})})]})}function Ty({chips:e,onClear:t,filterButton:n}){let r=y.useRef(null);if(!e.length)return null;let i=e=>requestAnimationFrame(()=>{let t=r.current?.querySelectorAll(`.ui-dt-chip`);(t?.[Math.min(e,t.length-1)]??n())?.focus()});return/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:r,className:`ui-dt-chips`,role:`group`,"aria-label":w(`套用的篩選`),children:[e.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:`ui-dt-chip`,"aria-label":w(`移除篩選:{name}`,{name:e.text}),onClick:()=>{e.remove(),i(t)},children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-chip-text`,children:e.text}),/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`,size:16})]},e.id)),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn ui-dt-chipclear`,onClick:()=>{t(),requestAnimationFrame(()=>n()?.focus())},children:w(`清除全部`)})]})}function Ey({filters:e,values:t,activeCount:n,count:r,onChange:i,onClear:a,boundary:o}){let[s,c]=y.useState(!1);return/* @__PURE__ */ (0,A.jsxs)(bv,{open:s,onOpenChange:c,boundary:o,className:`ui-dt-filterpop`,"aria-label":w(`篩選`),trigger:/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-btn`,`ui-btn-secondary`,`ui-dt-filterbtn`,s&&`is-open`,n>0&&`is-active`),"aria-label":n?w(`篩選,已套用 {n} 個條件`,{n}):void 0,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`funnel`,size:20}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-btntext`,children:w(`篩選`)}),n?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-pop-count`,children:n}):null]}),children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-filterhead`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-popover-title`,children:w(`篩選`)}),n?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn`,onClick:a,children:w(`清除全部`)}):null]}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dt-facets`,children:e.map(e=>{let n=t[e.key];if(e.type===`range`){let t=n&&!Array.isArray(n)?n:{min:``,max:``},r=n=>r=>i(e.key,{...t,[n]:r.target.value.replace(/[^\d.]/g,``)});return/* @__PURE__ */ (0,A.jsxs)(`fieldset`,{className:`ui-dt-facet`,children:[/* @__PURE__ */ (0,A.jsx)(`legend`,{children:e.label}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-range-inputs`,children:[/* @__PURE__ */ (0,A.jsx)(`input`,{className:`ui-input`,inputMode:`decimal`,"aria-label":`${e.label} ${w(`最低`)}`,placeholder:w(`最低`),value:t.min,onChange:r(`min`)}),/* @__PURE__ */ (0,A.jsx)(`span`,{children:`–`}),/* @__PURE__ */ (0,A.jsx)(`input`,{className:`ui-input`,inputMode:`decimal`,"aria-label":`${e.label} ${w(`最高`)}`,placeholder:w(`最高`),value:t.max,onChange:r(`max`)})]}),e.unitLabel?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-field-hint`,children:e.unitLabel}):null]},e.key)}let a=Array.isArray(n)?n:[];return/* @__PURE__ */ (0,A.jsxs)(`fieldset`,{className:`ui-dt-facet`,children:[/* @__PURE__ */ (0,A.jsx)(`legend`,{children:e.label}),e.options.map(t=>{let n=String(t.value),o=a.includes(n),s=r(e,n),c=e.multiple?o?a.filter(e=>e!==n):[...a,n]:o?[]:[n];return/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,role:e.multiple?`checkbox`:`radio`,"aria-checked":o,className:M(`ui-dt-opt`,o&&`is-on`,!s&&!o&&`is-zero`),onClick:()=>i(e.key,c),children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(e.multiple?`ui-check-box`:`ui-radio-ring`,o&&`is-on`),"aria-hidden":`true`,children:e.multiple?/* @__PURE__ */ (0,A.jsx)(E_,{v:o}):o?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-radio-dot`}):null}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-opt-label`,children:t.label}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-opt-n`,children:a_.number(s)})]},t.value)})]},e.key)})})]})}function Dy({text:e,children:t}){let n=H(B);return/* @__PURE__ */ (0,A.jsx)(Zf,{label:e,wrap:!0,describe:!1,disabled:n||!e,children:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-full`,children:t})})}function Oy({children:e}){let t=y.useRef(null),n=y.useRef(null),r=ee(),i=H(B),[a,o]=y.useState(!1),[s,c]=y.useState(!1),[l,u]=y.useState(``);y.useLayoutEffect(()=>{let e=n.current,o=t.current;if(!e||!o||a)return;let s=()=>{c(e.scrollHeight>e.clientHeight+1),u(!r&&!i&&o.scrollWidth>o.clientWidth+1?o.textContent??``:``)};s();let l=U(s);return l?.observe(o),()=>l?.disconnect()},[a,e,r,i]);let d=/* @__PURE__ */ (0,A.jsxs)(`span`,{ref:t,className:M(`ui-dt-long`,!!l&&`is-cut`),tabIndex:l?0:void 0,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{ref:n,className:M(`ui-dt-long-text`,!a&&`is-clamped`),children:e}),r&&(s||a)?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-dt-more`,onClick:e=>{e.stopPropagation(),o(!a)},children:w(a?`收合`:`顯示全部`)}):null]});return/* @__PURE__ */ (0,A.jsx)(Zf,{label:l,wrap:!0,disabled:!l,children:d})}Mr(),bn(),Ar(),ir(),ti(jr,yn,kr,rr);let ky=e=>w(e===`asc`?`由小到大`:`由大到小`),Ay={asc:`↑`,desc:`↓`};function jy(e,t){if(!e.length)return w(`已還原原本的順序`);let n=e=>t.find(t=>t.key===e)?.label??e;return w(`依 {list} 排序`,{list:e.map(e=>n(e.key)+` `+ky(e.dir)).join(w(`,再依 `))})}function My({cols:e,levels:t,max:n,onChange:r,boundary:i}){let[a,o]=y.useState(!1),[s,c]=y.useState(!1),[l,u]=y.useState(null),d=y.useRef(null),f=y.useRef(null),p=y.useId();y.useEffect(()=>{s&&f.current?.focus()},[s]);let m=t=>e.find(e=>e.key===t)?.label??t,h=t=>e.find(e=>e.key===t)?.numeric?`desc`:`asc`,g=e.filter(e=>!t.some(t=>t.key===e.key)),_=(e,n,i)=>{if(n<0||n>=t.length||e===n)return;let a=t.slice();a.splice(n,0,a.splice(e,1)[0]),r(a),i&&requestAnimationFrame(()=>d.current?.querySelectorAll(`.ui-dt-sortgrip`)[n]?.focus())},v=t.map(e=>m(e.key)+` `+Ay[e.dir]).join(w(`、`)),b=t.map(e=>m(e.key)+` `+ky(e.dir)).join(w(`、`));return/* @__PURE__ */ (0,A.jsxs)(bv,{open:a,onOpenChange:e=>{o(e),e||c(!1)},boundary:i,className:`ui-dt-sortpop`,"aria-label":w(`排序`),trigger:/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-btn`,`ui-btn-secondary`,`ui-dt-sortbtn`,a&&`is-open`,t.length>0&&`is-on`),"aria-label":t.length?w(`排序:{list}`,{list:b}):w(`排序`),children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`sort-ascending`,size:20}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-sortbtn-text`,children:t.length?w(`排序:{list}`,{list:v}):w(`排序`)}),t.length?/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-dt-sortbtn-short`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-btntext`,children:w(`排序`)}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-pop-count`,children:t.length})]}):null]}),children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-filterhead`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-popover-title`,children:w(`排序`)}),t.length?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn`,onClick:()=>r([]),children:w(`清除全部`)}):null]}),t.length?/* @__PURE__ */ (0,A.jsx)(`ol`,{className:`ui-dt-sortlist`,ref:d,children:t.map((e,n)=>/* @__PURE__ */ (0,A.jsxs)(`li`,{className:M(`ui-dt-sortlvl`,l?.from===n&&`is-dragging`,l&&l.over===n&&l.from!==n&&`is-over`),draggable:!0,onDragStart:e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(n)),u({from:n,over:n})},onDragOver:e=>{e.preventDefault(),l&&l.over!==n&&u({...l,over:n})},onDrop:e=>{e.preventDefault(),l&&_(l.from,n),u(null)},onDragEnd:()=>u(null),children:[/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-dt-sortgrip`,"aria-label":w(`「{name}」第 {n} 排序;按 Alt+↑ ↓ 調整順序`,{name:m(e.key),n:n+1}),"aria-keyshortcuts":`Alt+ArrowUp Alt+ArrowDown`,onKeyDown:e=>{!e.altKey||e.key!==`ArrowUp`&&e.key!==`ArrowDown`||(e.preventDefault(),_(n,n+(e.key===`ArrowUp`?-1:1),!0))},children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`dots-six-vertical`,size:16})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-sortn`,children:n+1}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-sortname`,children:m(e.key)}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-sortdir`,role:`radiogroup`,"aria-label":w(`「{name}」的方向`,{name:m(e.key)}),children:[`asc`,`desc`].map(i=>/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e.dir===i,className:M(e.dir===i&&`is-on`),onClick:()=>r(t.map((e,t)=>t===n?{key:e.key,dir:i}:e)),children:[Ay[i],` `,ky(i)]},i))}),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-dt-sortrm`,"aria-label":w(`移除「{name}」排序`,{name:m(e.key)}),onClick:()=>r(t.filter((e,t)=>t!==n)),children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`,size:16})})]},e.key))}):/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-dt-sortnone`,children:w(`照資料原本的順序。`)}),g.length&&t.length<n?s?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-sortadd`,role:`group`,"aria-labelledby":p,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{id:p,className:`ui-dt-sortaddhead`,children:t.length?w(`再依哪一欄`):w(`依哪一欄排序`)}),g.map((e,n)=>/* @__PURE__ */ (0,A.jsxs)(`button`,{ref:n===0?f:void 0,type:`button`,className:`ui-dt-opt`,onClick:()=>{r([...t,{key:e.key,dir:h(e.key)}]),c(!1)},children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`plus`,size:16}),e.label]},e.key))]}):/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:`ui-link-btn ui-dt-sortmore`,onClick:()=>c(!0),children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`plus`,size:16}),t.length?w(`再依…`):w(`排序依據…`)]}):t.length>=n&&g.length?/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-dt-sortnone`,children:w(`最多 {n} 層排序。`,{n})}):null]})}Fe(),qe(),ir(),ti(Pe,Ke,rr);let Ny={dur:320,stagger:25,ease:`cubic-bezier(.2,.8,.2,1)`},Py={asc:`M12 19V5M6 11l6-6 6 6`,desc:`M12 5v14M6 13l6 6 6-6`,none:`M8 9l4-4 4 4M8 15l4 4 4-4`},Fy=(e,t)=>e[t],Iy=e=>e.numeric||e.format===`money`||e.format===`percent`||e.format===`duration`,Ly=e=>Iy(e)||!!e.unit||dy(e)||e.mobile===`status`,Ry=(e,t)=>t?`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`:e.toISOString();function zy(e){let t=1/0,n=-1/0,r=document.createRange();if(typeof r.getBoundingClientRect!=`function`)return null;for(let i of e.childNodes){let e=null;if(i instanceof HTMLElement){if(i.classList.contains(`ui-col-resize`)||getComputedStyle(i).position===`absolute`)continue;e=i.getBoundingClientRect()}else i.nodeType===Node.TEXT_NODE&&i.textContent?.trim()&&(r.selectNodeContents(i),e=r.getBoundingClientRect());e&&e.width&&(t=Math.min(t,e.left),n=Math.max(n,e.right))}return n>t?n-t:0}let By=/* @__PURE__ */ new Set,Vy=/* @__PURE__ */ new Set,Hy=null,Uy=()=>Vy.forEach(e=>e());function Wy(e){if(!e.isConnected||e.closest(`[inert], [aria-hidden="true"]`))return!1;let t=e.checkVisibility;return typeof t==`function`?t.call(e,{checkVisibilityCSS:!0,visibilityProperty:!0}):e.getClientRects().length>0&&getComputedStyle(e).visibility!==`hidden`}let Gy=e=>e.querySelector(`:scope > .ui-dt-tools .ui-dt-search input`),Ky=()=>[...By].filter(e=>Wy(e)&&!!Gy(e)).sort((e,t)=>e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)[0]??null;function qy(e){if(e.key!==`/`||e.ctrlKey||e.metaKey||e.altKey||e.defaultPrevented||e.isComposing||(e.target instanceof Element?e.target:null)?.closest(`input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="textbox"], [role="searchbox"], [role="combobox"], [role="listbox"], [role="grid"], [role="treegrid"], [role="tree"], [role="menu"], [role="menubar"], [role="dialog"], [role="alertdialog"], dialog`))return;let t=Ky(),n=t?Gy(t):null;n&&(n.focus(),document.activeElement===n&&e.preventDefault())}function Jy(e,t){return By.size||document.addEventListener(`keydown`,qy),!Hy&&typeof ResizeObserver<`u`&&(Hy=new ResizeObserver(Uy)),By.add(e),Vy.add(t),Hy?.observe(e),Uy(),()=>{By.delete(e),Vy.delete(t),Hy?.unobserve(e),By.size||(document.removeEventListener(`keydown`,qy),Hy?.disconnect(),Hy=null),Uy()}}let Yy=e=>e.ctrlKey||e.metaKey||e.shiftKey||e.button===1,Xy=`a, button, input, select, textarea, label, [role="checkbox"], [role="button"], [role="menuitem"], [role="link"], [contenteditable]`;function Zy({v:e,label:t,onClick:n}){return/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,"aria-label":t,className:M(`ui-check-box`,`ui-dt-check`,e&&`is-on`),onMouseDown:e=>e.shiftKey&&e.preventDefault(),onClick:e=>{e.stopPropagation(),n(e)},children:/* @__PURE__ */ (0,A.jsx)(E_,{v:e})})}function Qy(e){let{columns:t,rows:n,pageSize:r=10,urlSync:i=!0,urlKey:a,search:o={},selectable:s=!1,stickyFirst:c=!1}=e,l=y.useMemo(()=>{let r=e.filters?[...e.filters]:[];return e.filter&&!r.length&&r.push({key:e.filter.key,label:e.filter.label||t.find(t=>t.key===e.filter?.key)?.label||e.filter.key,options:e.filter.options}),py(r,n)},[e.filters,e.filter,t,n]),u=()=>i&&typeof location<`u`?yy(a,l):{q:``,values:{}},d=Math.max(1,e.maxSort??1/0),f=t.filter(e=>e.sortable!==!1).map(e=>({key:e.key,label:e.label,numeric:Iy(e)})),p=e=>f.find(t=>t.key===e)?.numeric?`desc`:`asc`,m=e=>e.filter((t,n)=>f.some(e=>e.key===t.key)&&e.findIndex(e=>e.key===t.key)===n).slice(0,d).map(e=>({key:e.key,dir:e.dir??p(e.key)})),h=m(e.defaultSort??[]),[g,_]=y.useState(()=>m((i&&typeof location<`u`?xy(a):null)??h)),[v,x]=y.useState(0),[S,C]=y.useState(()=>u().q),[E,D]=y.useState(()=>u().values),[O,k]=y.useState(e.views?.[0]?.id??null),P=e.widthKey?`ui-dt-cols:`+e.widthKey:null,[I,R]=y.useState(()=>{if(!P)return{};try{let e=JSON.parse(localStorage.getItem(P)||`null`);return e&&typeof e==`object`?e:{}}catch{return{}}}),z=e=>{if(R(e),P)try{Object.keys(e).length?localStorage.setItem(P,JSON.stringify(e)):localStorage.removeItem(P)}catch{}},[V,U]=y.useState({}),ne=ee(),W=H(B),re=y.useId(),ie=y.useRef(null),[K,q]=y.useState({}),[ae,oe]=y.useState(`all`),[se,ce]=y.useState({}),[le,J]=y.useState(()=>{if(!e.widthKey)return null;try{let t=JSON.parse(localStorage.getItem(`ui-dt-width:`+e.widthKey)||`null`);return t&&typeof t==`object`?t:null}catch{return null}}),ue=t=>{if(J(t),e.widthKey)try{t?localStorage.setItem(`ui-dt-width:`+e.widthKey,JSON.stringify(t)):localStorage.removeItem(`ui-dt-width:`+e.widthKey)}catch{}},[de,fe]=y.useState(!1),[pe,me]=y.useState(null),he=y.useRef(null),[ge,_e]=y.useState(null),ve=o===!1&&!e.caption;y.useLayoutEffect(()=>{let e=ve?ie.current?.previousElementSibling:null;_e(e instanceof HTMLElement&&e.classList.contains(`ui-card-head`)&&e.parentElement?.classList.contains(`ui-card`)?e:null)},[ve]);let[ye,be]=y.useState(e.resetKey),xe=ye!==e.resetKey;xe&&(be(e.resetKey),C(``),D({}),x(0),q({}),oe(`all`),_(h),P||R({}),U({}),ce({}));let Se=JSON.stringify(E),Ce=JSON.stringify(g);y.useEffect(()=>{i&&typeof location<`u`&&Sy(a,g,h)},[Ce]),y.useEffect(()=>{i&&l.length&&by(a,l,E,S)},[Se,S]),G(t.some(e=>e.format===`percent`&&!e.unit),`DataTable`,`format: 'percent' sets 1 decimal and shows no % sign; add unit: '%' to that column.`),G(n.length>1&&n.every(e=>Fy(e,`id`)==null)&&s,`DataTable`,`rows have no id, so a selection follows the position, not the row. Add an id to each row.`),G(!!t[0]?.hidden,`DataTable`,`the first column is always shown, so its hidden: true does nothing. Move the column, or drop hidden.`),G((e.columnMenu===!1||t.length<=2)&&t.some((e,t)=>t>0&&e.hidden),`DataTable`,`a column has hidden: true but there is no 「欄位」 menu (columnMenu is false, or the table has 2 columns or fewer), so nobody can turn it on. Turn the menu on, or leave the column out.`);let we=e.summary?.key,Te=we?l.find(e=>e.key===we):void 0;G(Te,`DataTable`,`the filter 「${Te?.label}」 filters ${String(we)}, which the summary tabs already filter, so the same condition is in two places. Drop it from filters (or drop summary).`);let Ee=we&&n.length?e.views?.find(e=>{if(!e.filter)return!1;let t=n.filter(t=>e.filter?.(t));if(!t.length||t.length===n.length)return!1;let r=String(Fy(t[0],we));return t.every(e=>String(Fy(e,we))===r)&&n.filter(e=>String(Fy(e,we))===r).length===t.length}):void 0;G(Ee,`DataTable`,`the view 「${Ee?.label}」 keeps exactly the rows of one ${String(we)} value, which a summary tab already picks, so the same condition is in two places. Drop the view (or drop summary).`);for(let e of t){if(!e.unit&&!e.numeric)continue;let t=n.map(t=>Fy(t,e.key)).find(t=>typeof t==`string`&&/\d/.test(t)&&(e.unit?t.includes(e.unit):!/^\s*-?[\d,]*\.?\d+\s*$/.test(t)));G(t!==void 0,`DataTable`,`column 「${e.label}」 got the string 「${String(t)}」. Pass a number${e.unit?``:` and the unit in unit`} (e.g. { numeric: true, unit: '${e.unit||`字`}' } with 1234), so it is formatted, right-aligned and sorted as a number.`)}let De={};t.forEach((e,t)=>De[e.key]=t>0&&(I[e.key]??!!e.hidden));let Oe=t.filter(e=>!De[e.key]),{ref:ke,more:Ae,overflows:je,scrolled:Me,onScroll:Ne}=ny(),Pe=y.useRef(null),Fe=y.useRef({}),Ie=y.useRef(null),Le=n.map((e,t)=>({r:e,i:t})),Re=e.views?.find(e=>e.id===O);Re?.filter&&(Le=Le.filter(e=>Re.filter?.(e.r)));let ze=Le,Be=e.summary;Be&&ae!==`all`&&(Le=Le.filter(e=>String(Fy(e.r,Be.key))===ae));let Ve=Le.length,He=o!==!1&&!!S,Ue=(e,n)=>(!He||_y(e,t,l,S,o?o.keys:void 0))&&l.every(t=>t.key===n||gy(t,e,E[t.key])),We=Le.filter(e=>Ue(e.r)),Ge=l.filter(e=>hy(E[e.key])).length;if(g.length){let e=g.map(e=>{let n=t.find(t=>t.key===e.key);return{val:t=>{if(n?.sortValue)return n.sortValue(t);let r=Fy(t,e.key);return r instanceof Date||n&&dy(n)?fy(r)?.getTime()??-1/0:r},d:e.dir===`asc`?1:-1}});We=[...We].sort((t,n)=>{for(let{val:r,d:i}of e){let e=r(t.r),a=r(n.r),o=typeof e==`number`&&typeof a==`number`?e-a:String(e).localeCompare(String(a),`zh-Hant`);if(o)return o*i}return t.i-n.i})}let Ke=`${S}|${Se}|${ae}|${O}`,qe=y.useRef(Ke),Je=We.length;y.useEffect(()=>{if(Ke===qe.current)return;qe.current=``;let e=setTimeout(()=>bi(w(`顯示 {n} 筆`,{n:a_.number(Je)})),400);return()=>clearTimeout(e)},[Ke,Je]);let Ye=Math.max(1,Math.ceil(We.length/r)),Xe=Math.min(v,Ye-1),Ze=Xe*r,Qe=We.slice(Ze,Ze+r),$e=e=>{let t=Fy(e.r,`id`);return String(t??e.i)},et=new Set(We.map($e)),tt=Object.keys(K).filter(e=>K[e]&&et.has(e));!xe&&Object.keys(K).some(e=>K[e]&&!et.has(e))&&q(Object.fromEntries(tt.map(e=>[e,!0])));let nt=Qe.map($e),rt=nt.filter(e=>K[e]).length,it=nt.length>0&&rt===nt.length,at=rt>0&&!it,ot=e=>{let t=Pe.current;if(!t)return;let n=t.getBoundingClientRect().top,r={},i=[];for(let e of nt){let t=Fe.current[e];t&&(r[e]={top:t.getBoundingClientRect().top-n,bg:getComputedStyle(t).backgroundColor,node:t},i.push(e))}Ie.current={kind:e,rows:r,order:i}};y.useLayoutEffect(()=>{let e=Ie.current;Ie.current=null;let t=Pe.current;if(!e||!t||L()||typeof Element.prototype.animate!=`function`)return;let n=t.getBoundingClientRect().top,r=Math.max(e.order.length,nt.length),i=0,a=48;nt.forEach((t,o)=>{let s=Fe.current[t];if(!s)return;let c=s.getBoundingClientRect();a=c.height||a;let l=e.rows[t],u={duration:Ny.dur,delay:o*Ny.stagger,easing:Ny.ease,fill:`backwards`};if(l){let e=l.top-(c.top-n);s.animate([{transform:`translateY(${e}px)`,backgroundColor:l.bg},{transform:`none`,backgroundColor:getComputedStyle(s).backgroundColor}],u)}else{let t=e.kind===`next`?r:e.kind===`prev`?-r:r+i-o;i++,s.animate([{transform:`translateY(${t*a}px)`,opacity:0},{transform:`none`,opacity:1}],u)}}),e.order.forEach((n,i)=>{if(nt.includes(n))return;let o=e.rows[n],s=o.node.cloneNode(!0);s.removeAttribute(`data-rid`),s.setAttribute(`aria-hidden`,`true`),s.classList.add(`ui-dt-ghost`),s.style.top=o.top+`px`,s.style.backgroundColor=o.bg,t.appendChild(s);let c=e.kind===`next`?-r:e.kind===`prev`?r:r+1-i;s.animate([{transform:`none`,opacity:1},{transform:`translateY(${c*a}px)`,opacity:0}],{duration:Ny.dur,easing:Ny.ease,fill:`forwards`}).onfinish=()=>s.remove()})});let st=e=>{ot(`sort`),_(e),bi(jy(e,f))},ct=(e,t=!1)=>{if(e.sortable===!1)return;let n=p(e.key),r=n===`asc`?`desc`:`asc`,i=g.findIndex(t=>t.key===e.key);t?i<0?g.length<d?st([...g,{key:e.key,dir:n}]):bi(w(`最多 {n} 層排序。`,{n:d})):g[i].dir===n?st(g.map((e,t)=>t===i?{key:e.key,dir:r}:e)):st(g.filter((e,t)=>t!==i)):g.length!==1||i!==0?st([{key:e.key,dir:n}]):g[0].dir===n?st([{key:e.key,dir:r}]):st([])},lt=e=>{e===Xe||e<0||e>=Ye||(ot(e>Xe?`next`:`prev`),x(e))},ut=(e,t)=>q({...K,...Object.fromEntries(e.map(e=>[e,t]))}),dt=()=>q({}),ft=y.useRef(null),pt=`${Ke}|${Ce}|${r}`;y.useEffect(()=>{ft.current=null},[pt]);let mt=(e,t,n)=>{let r=We.map($e),i=n&&ft.current?r.indexOf(ft.current):-1,a=r.indexOf(e);if(ft.current=e,i<0||a<0||i===a)return ut([e],!t);let o={...K,...Object.fromEntries(r.slice(Math.min(i,a),Math.max(i,a)+1).map(e=>[e,!t]))};q(o),bi(w(`已選 {n} 筆`,{n:r.filter(e=>o[e]).length}))},ht=()=>{D({}),C(``),x(0)},gt=!!e.rowActions,_t=e.actionsWidth||88,vt=Oe.some(e=>e.mobile===`title`),yt=(e,t)=>{let n=e.mobile||(!vt&&t===0?`title`:null);return n?`is-m-`+n:null},bt=Oe.filter(e=>e.long||e.fullText),xt=bt.length>0&&!ne,St=(Oe.find(e=>!Ly(e)&&!e.long&&e.grow!==0)??Oe[0])?.key,Ct=e=>e.grow==null?e.long||e.key===St:e.grow>0,wt=e=>{if(Ct(e))return Math.max(e.width||(Iy(e)?96:120),se[e.key]||0);let t=e.width==null&&!Ly(e)?280:1/0;return Math.max(e.width||0,48,Math.min(se[e.key]??e.width??96,t))},Tt=e=>({gridTemplateColumns:[xt?`40px`:null,s?`46px`:null,...Oe.map(t=>e?`${e[t.key]??wt(t)}px`:Ct(t)?`minmax(${wt(t)}px, ${t.grow||1}fr)`:`${wt(t)}px`),gt?_t+`px`:null].filter(Boolean).join(` `),minWidth:(xt?40:0)+(s?46:0)+Oe.reduce((t,n)=>t+(e?e[n.key]??wt(n):wt(n)),0)+(gt?_t:0)}),Et=Tt(le),Dt=Tt(pe),Ot=e=>{let t={};for(let n of Oe){let r=e?.querySelector(`.ui-dt-head [data-col="${CSS.escape(n.key)}"]`);t[n.key]=r?Math.ceil(r.getBoundingClientRect().width):wt(n)}return t},kt=(e,t)=>{let n=e?.querySelector(`.ui-dt-head [data-col="${CSS.escape(t)}"] > :first-child`);return Math.max(48,n?Math.ceil(n.getBoundingClientRect().width)+24:48)},At=y.useRef(()=>{});y.useLayoutEffect(()=>{let e=ie.current;if(!e||ne)return;let t=()=>{let t={};for(let n of e.querySelectorAll(`:scope > .ui-dt-scroller .ui-dt-body .ui-dt-cell[data-col]:not(.is-long):not(.is-hug)`)){let e=n.scrollWidth-n.clientWidth,r=n.dataset.col;e>1&&r&&(t[r]=Math.max(t[r]??0,Math.ceil(n.getBoundingClientRect().width+e)))}let n=e.querySelectorAll(`:scope > .ui-dt-scroller .ui-dt-cell.is-hug[data-col]`);if(n.length){e.classList.add(`is-measuring`);for(let e of n){let n=e.dataset.col,r=zy(e.querySelector(`:scope > .ui-dt-stack > .ui-dt-main`)??e);n&&r!==null&&(t[n]=Math.max(t[n]??0,Math.ceil(r+25)))}e.classList.remove(`is-measuring`)}ce(e=>{let n=Object.entries(t).filter(([t,n])=>n>(e[t]??0));return n.length?{...e,...Object.fromEntries(n)}:e})},n=0,r=()=>{n||=requestAnimationFrame(()=>{n=0,t()})};At.current=r,t();let i=new MutationObserver(r);for(let t of e.querySelectorAll(`:scope > .ui-dt-scroller .ui-dt-table, :scope > .ui-dt-scroller .ui-dt-body`))i.observe(t,{childList:!0});return document.fonts?.ready.then(r).catch(()=>{}),()=>{i.disconnect(),cancelAnimationFrame(n),At.current=()=>{}}},[ne,ye]);let jt=`${nt.join(``)}|${Oe.map(e=>e.key).join(`,`)}|${We.length}|${S}|${!!e.totals}`;y.useLayoutEffect(()=>{At.current()},[jt,n]);let Mt=e=>e===0&&c?{left:(xt?40:0)+(s?46:0)}:void 0,Nt=(e,t,...n)=>M(`ui-dt-cell`,Iy(e)&&`is-num`,!Ct(e)&&`is-hug`,t===0&&c&&`is-sticky is-sticky-end`,...n),Pt=e=>c?{className:`is-sticky`,style:{left:e===`sel`&&xt?40:0}}:{className:void 0,style:void 0},Ft=t=>{let n=t?Dt:Et,r=n.minWidth,i=t?pe:le,a=t?me:ue,o=()=>t?he.current:ie.current;return s&&tt.length&&e.bulkActions?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-row ui-dt-head ui-dt-bulk`,role:`row`,style:{minWidth:r},children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dt-cell`,role:`columnheader`,children:/* @__PURE__ */ (0,A.jsx)(Zy,{v:it?!0:`mixed`,label:w(`全選`),onClick:()=>ut(nt,!it)})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-bulk-count`,children:w(`已選 {n} 筆`,{n:tt.length})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-bulk-actions`,children:e.bulkActions(tt,dt)}),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-dt-bulk-close`,"aria-label":w(`取消選取`),onClick:dt,children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`,size:14})})]}):/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-row ui-dt-head`,role:`row`,style:n,children:[xt?/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-dt-cell ui-dt-exp`,Pt(`exp`).className),style:Pt(`exp`).style,role:`columnheader`,"aria-label":w(`詳細`)}):null,s?/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-dt-cell ui-dt-sel`,Pt(`sel`).className),style:Pt(`sel`).style,role:`columnheader`,children:/* @__PURE__ */ (0,A.jsx)(Zy,{v:it?!0:at?`mixed`:!1,label:w(`全選`),onClick:()=>ut(nt,!it)})}):null,Oe.map((e,t)=>{let n=g.findIndex(t=>t.key===e.key),r=n>=0,s=g.length>1;return/* @__PURE__ */ (0,A.jsxs)(`div`,{role:`columnheader`,"aria-sort":n===0?g[0].dir===`asc`?`ascending`:`descending`:`none`,className:Nt(e,t),style:Mt(t),"data-col":e.key,children:[e.sortable===!1?e.label:/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-dt-sort`,r&&`is-on`),"aria-label":r&&s?w(`{name},第 {n} 排序,{dir}`,{name:e.label,n:n+1,dir:ky(g[n].dir)}):void 0,"aria-keyshortcuts":`Shift+Enter`,onClick:t=>ct(e,t.shiftKey),onKeyDown:t=>{t.shiftKey&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),ct(e,!0))},children:[/* @__PURE__ */ (0,A.jsx)(`span`,{children:e.label}),/* @__PURE__ */ (0,A.jsx)(Y,{d:Py[r?g[n].dir:`none`],size:14,className:`ui-dt-arrow`}),r&&s?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-sortpri`,"aria-hidden":`true`,children:n+1}):null]}),ne?null:/* @__PURE__ */ (0,A.jsx)(iy,{name:e.label,width:i?.[e.key]??wt(e),start:()=>(i??Ot(o()))[e.key]??wt(e),onWidth:t=>a({...i??Ot(o()),[e.key]:Math.max(kt(o(),e.key),t)}),onReset:()=>a(null)})]},e.key)}),gt?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dt-cell`,role:`columnheader`,"aria-label":w(`操作`)}):null]})},It=He?S:``,Lt=(e,t)=>{if(t.format!==`relative`||t.render)return``;let n=fy(Fy(e,t.key)),r=n?a_.dateTime(n):``;return r&&r!==a_.relative(n)?r:``},Rt=(e,t)=>{let n=Fy(e,t.key),r;if(t.render)r=t.render(e);else if(dy(t)&&fy(n)){let i=fy(n),a=Lt(e,t),o=/* @__PURE__ */ (0,A.jsx)(`time`,{className:`ui-dt-time`,dateTime:Ry(i,t.format===`date`),children:Cy(ly(t,n),It)});r=a?/* @__PURE__ */ (0,A.jsx)(Zf,{label:a,describe:!1,disabled:W,children:o}):o}else r=t.unit&&n!=null&&n!==``?/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-dt-qty`,children:[Cy(ly({...t,unit:void 0},n),It),` `,/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-unit`,children:t.unit})]}):Cy(ly(t,n),It);return r},zt=e=>{let t=e.target.closest(Xy);if(t&&t!==e.currentTarget)return!1;let n=window.getSelection();return!(n&&!n.isCollapsed&&String(n).trim())},Bt=(t,n)=>{let r=e.rowHref?.(t);r!=null&&(Yy(n)?(n.preventDefault(),window.open(r,`_blank`,`noopener`)):e.onRowOpen?e.onRowOpen(t,n):n.currentTarget.querySelector(`a.ui-dt-rowlink`)?.click())},Vt=(t,n,r)=>{let i=n.long?/* @__PURE__ */ (0,A.jsx)(Oy,{children:Rt(t,n)}):Rt(t,n);n.fullText&&(i=/* @__PURE__ */ (0,A.jsx)(Dy,{text:n.fullText(t),children:i})),r===0&&e.rowHref&&(i=/* @__PURE__ */ (0,A.jsx)(`a`,{className:`ui-dt-rowlink`,href:e.rowHref(t),onClick:e.onRowOpen?n=>{Yy(n)||(n.preventDefault(),e.onRowOpen?.(t,n))}:void 0,children:i}));let a=n.secondary?.(t);return a==null||a===``||a===!1?i:/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-dt-stack`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-main`,children:i}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-sub`,children:a})]})},Ht=(t,n)=>{let r=e.totals?.[t.key],i=We.map(e=>e.r);if(n===0&&!r)return/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-qty`,children:F(w(`合計 {n} 筆`,{n:``}),[a_.number(i.length)])});if(typeof r==`function`)return r(i);if(r===`sum`||r===`avg`){let e=i.reduce((e,n)=>e+(Number(Fy(n,t.key))||0),0),n=r===`sum`?e:e/(i.length||1),a=ly({...r===`avg`&&!t.format?{...t,decimals:1}:t,unit:void 0},n);return/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-dt-qty`,children:[r===`avg`?/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-unit`,children:[w(`平均`),` `]}):null,a,t.unit?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[` `,/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-unit`,children:t.unit})]}):null]})}return``},Ut=()=>{let t=We.map(e=>e.r);return e.copyText?e.copyText(t):sy(Oe.map(e=>e.label),t.map(e=>Oe.map(t=>String(t.fullText?.(e)??t.searchText?.(e)??ly(t,Fy(e,t.key))??``))))},[Wt,Gt]=y.useState(!1),Kt=y.useRef(void 0);y.useEffect(()=>()=>clearTimeout(Kt.current),[]);let qt=()=>te(Ut()).then(()=>{Gt(!0),bi(w(`已複製`)),clearTimeout(Kt.current),Kt.current=setTimeout(()=>Gt(!1),2e3)},()=>e.onCopyError?.()),Jt=o!==!1&&e.searchShortcut!==!1,[Yt,Xt]=y.useState(!1);y.useEffect(()=>{let e=ie.current;if(!Jt||!e)return;let t=Jy(e,()=>Xt(Ky()===e));return()=>{t(),Xt(!1)}},[Jt]);let[Zt,Qt]=y.useState(!1),$t=(e,t)=>{D(t===void 0?Object.fromEntries(Object.entries(E).filter(([t])=>t!==e)):{...E,[e]:t}),x(0)},en=[];for(let e of l){let t=E[e.key];if(t&&hy(t)){if(Array.isArray(t))for(let n of t)en.push({id:e.key+`=`+n,text:w(`{name}:{value}`,{name:e.label,value:e.options.find(e=>String(e.value)===n)?.label??n}),remove:()=>$t(e.key,t.filter(e=>e!==n))});else{let n=t.min&&t.max?`${t.min}–${t.max}`:t.min?`≥ ${t.min}`:`≤ ${t.max}`;en.push({id:e.key,text:w(`{name}:{value}`,{name:e.label,value:n}),remove:()=>$t(e.key,void 0)})}}}let tn=e=>/* @__PURE__ */ (0,A.jsx)(Ty,{chips:en,onClear:()=>{D({}),x(0)},filterButton:()=>(e?he:ie).current?.querySelector(`.ui-dt-filterbtn`)??null}),nn=(n,r=!1)=>/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-dt-tools`,r&&`is-inhead`),children:[o===!1&&e.caption&&!n&&!r?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dt-caption`,children:e.caption}):null,o===!1?null:/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-search`,onFocus:()=>Qt(!0),onBlur:()=>Qt(!1),children:[/* @__PURE__ */ (0,A.jsx)(ey,{value:S,onChange:e=>{C(e),x(0)},placeholder:o.placeholder||w(`搜尋`),label:o.placeholder||w(`搜尋`),"aria-keyshortcuts":Yt&&!n?`/`:void 0,className:`ui-dt-searchfield`}),Yt&&!n&&!ne&&!S&&!Zt?/* @__PURE__ */ (0,A.jsx)(`kbd`,{className:`ui-dt-kbd`,"aria-hidden":`true`,children:`/`}):null]}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-actions`,children:[l.length?/* @__PURE__ */ (0,A.jsx)(Ey,{boundary:n?he:ie,filters:l,values:E,activeCount:Ge,count:(e,t)=>Le.filter(n=>Ue(n.r,e.key)&&gy(e,n.r,e.type===`list`?[t]:void 0)).length,onChange:(e,t)=>$t(e,t),onClear:()=>{D({}),x(0)}}):null,/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-dt-result`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{"aria-hidden":`true`,children:N(w(`{n} / {total} 筆`,{n:``,total:``}),[a_.number(We.length),a_.number(Ve)])}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:a_.fractionLabel(We.length,Ve,w(`筆`))})]}),f.length?/* @__PURE__ */ (0,A.jsx)(My,{cols:f,levels:g,max:d,onChange:st,boundary:n?he:ie}):null,ne?null:/* @__PURE__ */ (0,A.jsx)(wy,{columns:e.columnMenu!==!1&&t.length>2?{cols:t,hidden:De,onToggle:e=>z({...I,[e]:!De[e]}),onReset:()=>{z({}),ue(null),me(null),bi(w(`已還原預設的欄位與欄寬`))}}:void 0,onCopy:e.copy===!1?void 0:qt,onZoom:e.zoom!==!1&&!n?()=>fe(!0):void 0}),Wt&&!ne?/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-dt-copied`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`check`,size:16}),w(`已複製`)]}):null]})]}),rn=t=>{let n=t?Dt:Et,r=t?re+`z`:re;return/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-dt-scroller`,Ae&&!t&&`has-more`),children:/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-dt-scroll`,Ye>1&&`is-paged`),ref:t?void 0:ke,onScroll:t?void 0:Ne,children:/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-table`,role:`table`,"aria-label":e.label||e.caption,children:[Ft(t),/* @__PURE__ */ (0,A.jsx)(`div`,{ref:t?void 0:Pe,className:`ui-dt-body`,role:`rowgroup`,children:Qe.length?Qe.map((i,a)=>{let o=nt[a],c=!!K[o],l=xt&&!!V[o],u=`${r}-d-${j(o)}`,d=Oe[0]?String(ly(Oe[0],Fy(i.r,Oe[0].key))??``):``;return/* @__PURE__ */ (0,A.jsxs)(y.Fragment,{children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{"data-rid":o,ref:t?void 0:e=>{Fe.current[o]=e},role:`row`,"aria-labelledby":Oe.length?`${r}-n-${Ze+a}`:void 0,className:M(`ui-dt-row`,a%2&&`is-even`,c&&`is-selected`,s&&`has-sel`,xt&&!e.rowHref&&`has-exp`,e.rowHref&&`has-href`),style:n,onClick:xt||e.rowHref?t=>{if(zt(t)){if(e.rowHref)return Bt(i.r,t);U({...V,[o]:!l})}}:void 0,onMouseDown:e.rowHref?e=>{(e.shiftKey||e.button===1)&&!e.target.closest(Xy)&&e.preventDefault()}:void 0,onAuxClick:e.rowHref?e=>{e.button===1&&zt(e)&&Bt(i.r,e)}:void 0,children:[xt?/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-dt-cell ui-dt-exp`,Pt(`exp`).className),style:Pt(`exp`).style,role:`cell`,children:/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:M(`ui-dt-exp-btn`,l&&`is-open`),"aria-expanded":l,"aria-controls":l?u:void 0,"aria-label":w(l?`收合 {name}`:`展開 {name}`,{name:d}),onClick:()=>U({...V,[o]:!l}),children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-right`,size:16})})}):null,s?/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-dt-cell ui-dt-sel`,Pt(`sel`).className),style:Pt(`sel`).style,role:`cell`,children:/* @__PURE__ */ (0,A.jsx)(Zy,{v:c,label:w(`選取第 {n} 筆`,{n:Ze+a+1}),onClick:e=>mt(o,c,e.shiftKey)})}):null,Oe.map((e,t)=>/* @__PURE__ */ (0,A.jsx)(`div`,{role:`cell`,id:t===0?`${r}-n-${Ze+a}`:void 0,"aria-description":[e.fullText?.(i.r),Lt(i.r,e)].filter(Boolean).join(`,`)||void 0,"data-label":e.label,"data-col":e.key,className:Nt(e,t,e.long&&`is-long`,yt(e,t)),style:Mt(t),children:Vt(i.r,e,t)},e.key)),gt?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dt-cell ui-dt-acts`,role:`cell`,children:e.rowActions?.(i.r)}):null]}),l?/* @__PURE__ */ (0,A.jsx)(`div`,{id:u,role:`row`,className:M(`ui-dt-detail`,a%2&&`is-even`),style:{minWidth:n.minWidth},children:/* @__PURE__ */ (0,A.jsx)(`div`,{role:`cell`,className:`ui-dt-detail-cell`,style:{paddingLeft:40+(s?46:0)+12},children:bt.map(e=>/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-detail-item`,children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dt-detail-label`,children:e.label}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dt-detail-text`,children:e.fullText?e.fullText(i.r):Rt(i.r,e)})]},e.key))})}):null]},o)}):/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-empty`,children:[e.emptyText||w(`沒有符合的資料`),S||Ge?/* @__PURE__ */ (0,A.jsx)(`div`,{children:/* @__PURE__ */ (0,A.jsx)(Xp,{onClick:ht,children:w(`清除篩選`)})}):null]})}),e.totals&&We.length?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-row ui-dt-total`,role:`row`,style:n,children:[xt?/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-dt-cell`,Pt(`exp`).className),style:Pt(`exp`).style,role:`cell`}):null,s?/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-dt-cell`,Pt(`sel`).className),style:Pt(`sel`).style,role:`cell`}):null,Oe.map((t,n)=>/* @__PURE__ */ (0,A.jsx)(`div`,{role:`cell`,className:Nt(t,n),style:Mt(n),"data-col":t.key,"data-label":n>0&&e.totals?.[t.key]?t.label:void 0,children:Ht(t,n)},t.key)),gt?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dt-cell`,role:`cell`}):null]}):null]})})})},an=/* @__PURE__ */ (0,A.jsx)(A.Fragment,{children:Ye>1?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-foot`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-range`,children:F(w(`第 {a}–{b} 筆,共 {n} 筆`,{a:``,b:``,n:``}),[Ze+1,Math.min(We.length,Ze+r),a_.number(We.length)])}),/* @__PURE__ */ (0,A.jsxs)(`nav`,{className:`ui-dt-pages`,"aria-label":w(`分頁`),children:[/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-dt-page`,"aria-label":w(`上一頁`),disabled:Xe===0,onClick:()=>lt(Xe-1),children:`‹`}),Array.from({length:Ye},(e,t)=>/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:M(`ui-dt-page`,t===Xe&&`is-on`),"aria-current":t===Xe?`page`:void 0,onClick:()=>lt(t),children:String(t+1)},t)),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-dt-page`,"aria-label":w(`下一頁`),disabled:Xe>=Ye-1,onClick:()=>lt(Xe+1),children:`›`})]})]}):null});return/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:ie,className:M(`ui-dt`,o===!1&&`is-nosearch`,tt.length&&`has-sel`,e.className),children:[e.caption&&o!==!1?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dt-caption`,children:e.caption}):null,e.views?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dt-views`,role:`tablist`,"aria-label":w(`檢視`),children:e.views.map(e=>{let t=e.id===O,r=n.filter(t=>!e.filter||e.filter(t)).length;return/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,className:M(`ui-dt-view`,t&&`is-on`),onClick:()=>{k(e.id),x(0)},children:[e.label,/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-dt-view-n`,children:[a_.number(r),` `,/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-unit`,children:T(`筆`,r)})]})]},e.id)})}):null,Be?/* @__PURE__ */ (0,A.jsx)(ty,{className:`ui-dt-summary`,label:Be.label||w(`依狀態篩選`),unit:Be.unit||`筆`,value:ae,onChange:e=>{ot(`sort`),oe(e),x(0)},items:[{id:`all`,label:w(`全部`),count:ze.length},...Be.items.map(e=>({id:String(e.value),label:e.label,count:ze.filter(t=>String(Fy(t.r,Be.key))===String(e.value)).length}))]}):null,ge?(0,b.createPortal)(nn(!1,!0),ge):nn(!1),tn(!1),rn(!1),/* @__PURE__ */ (0,A.jsx)(ry,{show:je,done:Me}),an,/* @__PURE__ */ (0,A.jsx)(oy,{open:de,onClose:()=>fe(!1),title:e.caption||e.label,children:/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:he,className:`ui-dt ui-dt-zoomed`,children:[nn(!0),tn(!0),rn(!0),an]})})]})}ke(),ti(Oe);function $y({label:e,value:t,onChange:n,hint:r,required:i,error:a,className:o}){let s=y.useId(),[c,l]=y.useState(!1),[u,d]=y.useState(null),f=y.useRef(null),p=u!==null&&u!==``&&!s_(u),[m,h]=y.useState(!1),g=p&&m?w(`日期格式不正確,請寫成 2026/11/14`):a,_=s+`-msg`,v=e=>{d(null),h(!1),n(e),l(!1)};return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-field`,g&&`has-error`,o),children:[e?/* @__PURE__ */ (0,A.jsx)(T_,{htmlFor:s,required:i,children:e}):null,/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:f,className:M(`ui-datefield`,g&&`is-invalid`),children:[/* @__PURE__ */ (0,A.jsx)(`input`,{id:s,className:`ui-datefield-input`,value:u??o_(t),placeholder:`YYYY/MM/DD`,"aria-required":i||void 0,"aria-invalid":g?!0:void 0,"aria-describedby":_,onChange:e=>{let t=e.target.value;d(t);let r=s_(t);r?n(r):t===``&&n(null)},onBlur:()=>p?h(!0):d(null)}),g?/* @__PURE__ */ (0,A.jsx)(D_,{inline:!0}):null,/* @__PURE__ */ (0,A.jsxs)(bv,{open:c,onOpenChange:l,anchor:f,className:`ui-datepop`,"aria-label":w(`選擇日期`),trigger:/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-datefield-btn`,"aria-label":w(`開啟日曆`),children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`calendar-blank`,size:18})}),children:[/* @__PURE__ */ (0,A.jsx)(S_,{focus:t,dayState:e=>({selected:c_(e,t)}),onPick:v}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-datepop-foot`,children:[/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn`,onClick:()=>v(new Date((/* @__PURE__ */ new Date()).setHours(0,0,0,0))),children:w(`今天`)}),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn is-muted`,onClick:()=>v(null),children:w(`清除`)})]})]})]}),/* @__PURE__ */ (0,A.jsx)(O_,{id:_,error:g,hint:r||w(`可以直接輸入,例如 2026/11/14`)})]})}ke(),ti(Oe);let eb=e=>a_.date(e,{weekday:!1});function tb({label:e,value:t,onChange:n,placeholder:r,className:i}){let[a,o]=y.useState(!1),[s,c]=y.useState(null),[l,u]=y.useState(null),d=/* @__PURE__ */ new Date;d.setHours(0,0,0,0);let f=[[w(`今天`),[d,d]],[w(`最近 7 天`),[l_(d,-6),d]],[w(`最近 30 天`),[l_(d,-29),d]],[w(`本月`),[new Date(d.getFullYear(),d.getMonth(),1),new Date(d.getFullYear(),d.getMonth()+1,0)]],[w(`上個月`),[new Date(d.getFullYear(),d.getMonth()-1,1),new Date(d.getFullYear(),d.getMonth(),0)]]],p=e=>{o(e),e||c(null)},m=e=>{n(e),p(!1)},h=s||t[0],g=s?l||s:t[1],_=h&&g&&g<h?g:h,v=h&&g&&g<h?h:g;return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-field`,i),children:[e?/* @__PURE__ */ (0,A.jsx)(T_,{children:e}):null,/* @__PURE__ */ (0,A.jsxs)(bv,{open:a,onOpenChange:p,className:`ui-datepop ui-rangepop`,"aria-label":w(`選擇期間`),trigger:/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-datefield`,`ui-rangefield`,a&&`is-open`),"aria-label":t[0]?w(`{label}:{a} 到 {b}`,{label:e||w(`期間`),a:eb(t[0]),b:eb(t[1])}):`${e||w(`期間`)}${w(`:`)}${r||w(`選擇期間`)}`,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`calendar-blank`,size:18}),/* @__PURE__ */ (0,A.jsx)(`span`,{children:t[0]?`${eb(t[0])} – ${eb(t[1])}`:r||w(`選擇期間`)})]}),children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-quick`,children:f.map(([e,n])=>/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:M(`ui-quick-btn`,c_(n[0],t[0])&&c_(n[1],t[1])&&`is-on`),onClick:()=>m(n),children:e},e))}),/* @__PURE__ */ (0,A.jsx)(S_,{focus:t[1]||t[0],onHover:s?u:void 0,dayState:e=>({selected:c_(e,_)||c_(e,v),start:c_(e,_),end:c_(e,v),inRange:!!_&&!!v&&e>_&&e<v}),onPick:e=>{s?m(s<=e?[s,e]:[e,s]):(c(e),u(e))}})]})]})}function nb({items:e,labelWidth:t,labelSize:n,className:r}){return/* @__PURE__ */ (0,A.jsx)(`dl`,{className:M(`ui-dl`,t===`auto`&&`is-auto`,typeof t==`number`&&`is-fixed`,n===`body`&&`is-body`,r),style:typeof t==`number`?{"--dl-label":t+`px`}:void 0,children:e.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dl-item`,children:[/* @__PURE__ */ (0,A.jsx)(`dt`,{children:e.label}),/* @__PURE__ */ (0,A.jsx)(`dd`,{children:e.value})]},t))})}let rb=e=>{if(!e)return null;try{let t=Number(window.localStorage.getItem(`ui-split:`+e));return Number.isFinite(t)&&t>0?t:null}catch{return null}},ib=(e,t)=>{if(e)try{window.localStorage.setItem(`ui-split:`+e,String(Math.round(t)))}catch{}};function ab({a:e,b:t,defaultB:n=420,minA:r=360,minB:i=280,storageKey:a,label:o,onResize:s,className:c}){G(n<i,`SplitPane`,`defaultB (${n} px) is under minB (${i} px): the panel starts at ${i} px. Raise defaultB or lower minB.`);let l=y.useRef(null),[u,d]=y.useState(0),[f,p]=y.useState(()=>(typeof window>`u`?null:rb(a))??n),[m,h]=y.useState(!1),g=y.useRef(!1),_=y.useId();y.useLayoutEffect(()=>{let e=l.current;if(!e)return;let t=()=>d(e.clientWidth);t();let n=U(t);return n?.observe(e),()=>n?.disconnect()},[]);let v=u>0&&u<960,b=Math.max(i,u-16-r),x=Math.round(Math.min(b,Math.max(i,f))),S=Math.max(0,u-16-x),C=y.useRef(x),T=(e,t=!0)=>{let n=Math.round(Math.min(b,Math.max(i,e)));C.current=n,p(n),t&&ib(a,n),s?.(n)},E=e=>{if(W(e))return;let t=e.key===`ArrowLeft`?x+16:e.key===`ArrowRight`?x-16:e.key===`Home`?b:e.key===`End`?i:e.key===`Enter`?n:null;t!=null&&(e.preventDefault(),T(t))},D=e=>{if(e.button===0){e.preventDefault();try{e.currentTarget.setPointerCapture?.(e.pointerId)}catch{}e.currentTarget.focus({preventScroll:!0}),g.current=!0,h(!0)}},O=e=>{if(!g.current||!l.current)return;let t=l.current.getBoundingClientRect();T(t.right-e.clientX-8,!1)},k=e=>{if(g.current){g.current=!1,h(!1);try{e.currentTarget.hasPointerCapture?.(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)}catch{}l.current&&ib(a,C.current)}};return/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:l,className:M(`ui-split`,v&&`is-stacked`,m&&`is-dragging`,c),style:v||!u?void 0:{gridTemplateColumns:`minmax(0, 1fr) 16px ${x}px`},children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-split-a`,children:e}),v?null:/* @__PURE__ */ (0,A.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":o||w(`調整面板寬度`),"aria-controls":_,"aria-valuenow":S,"aria-valuemin":r,"aria-valuemax":Math.max(r,u-16-i),"aria-valuetext":w(`主要區域 {a} px,面板 {b} px`,{a:S,b:x}),className:`ui-split-handle`,onKeyDown:E,onPointerDown:D,onPointerMove:O,onPointerUp:k,onPointerCancel:k,onDoubleClick:()=>T(n),children:/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-split-grip`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsx)(`i`,{}),/* @__PURE__ */ (0,A.jsx)(`i`,{}),/* @__PURE__ */ (0,A.jsx)(`i`,{})]})}),/* @__PURE__ */ (0,A.jsx)(`div`,{id:_,className:`ui-split-b`,children:t})]})}function ob({title:e,description:t,steps:n=[],current:r=0,action:i}){return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-empty`,children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-empty-title`,children:e}),t?/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-empty-desc`,children:t}):null,n.length?/* @__PURE__ */ (0,A.jsx)(`ol`,{className:`ui-steps`,children:n.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`li`,{className:t===r?`is-current`:void 0,"aria-current":t===r?`step`:void 0,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-step-num`,children:t+1}),/* @__PURE__ */ (0,A.jsx)(`span`,{children:e})]},t))}):null,i??null]})}let sb={404:[`找不到這個頁面`,`網址可能打錯了,或這個頁面已經移除。`],500:[`伺服器暫時無法回應`,`這個問題已經記錄下來,請稍後重新整理再試。`],403:[`沒有權限查看這個頁面`,`請向管理員申請權限,或切換成有權限的帳號。`]};function cb({code:e,title:t,description:n,onBack:r,onHome:i,homeHref:a=`/`,className:o}){let s=sb[e];return/* @__PURE__ */ (0,A.jsxs)(`main`,{className:M(`ui-errorpage`,o),children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-errorpage-code`,"aria-hidden":`true`,children:e}),/* @__PURE__ */ (0,A.jsx)(`h1`,{className:`ui-errorpage-title`,children:t||w(s?s[0]:`發生錯誤`)}),/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-errorpage-desc`,children:n||(s?w(s[1]):``)}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-errorpage-actions`,children:[/* @__PURE__ */ (0,A.jsx)(Xp,{onClick:r??(()=>history.back()),children:w(`回上一頁`)}),/* @__PURE__ */ (0,A.jsx)(Xp,{variant:`primary`,onClick:i??(()=>location.href=a),children:w(`回首頁`)})]})]})}function lb({value:e,label:t,className:n,...r}){let i=Math.max(0,Math.min(100,e||0)),a=i>=100;return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-progress`,a&&`is-done`,n),children:[t?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-field-label`,children:t}):null,/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-progress-track`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(i),"aria-label":t||r[`aria-label`],children:/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-progress-fill`,style:{width:i+`%`}})}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-progress-text`,children:a?w(`完成 ✓`):Math.round(i)+`%`})]})}xt(),Jn(),ir(),ti(bt,qn,rr);function ub({label:e,files:t=[],onAdd:n,onRemove:r,onRetry:i,limitText:a,accept:o,multiple:s=!0,className:c}){let[l,u]=y.useState(!1),d=y.useRef(null),f=e=>{let t=Array.from(e??[]);t.length&&n?.(t)};return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-upload`,c),children:[e?/* @__PURE__ */ (0,A.jsx)(T_,{children:e}):null,/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-dropline`,l&&`is-drag`),onDragOver:e=>{e.preventDefault(),u(!0)},onDragLeave:()=>u(!1),onDrop:e=>{e.preventDefault(),u(!1),f(e.dataTransfer.files)},children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`upload-simple`,size:18}),/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-dropline-text`,children:[w(`拖放檔案,或 `),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn`,onClick:()=>d.current?.click(),children:w(`選擇檔案`)})]}),a?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dropline-limit`,children:a}):null,/* @__PURE__ */ (0,A.jsx)(`input`,{ref:d,type:`file`,multiple:s,accept:o,hidden:!0,onChange:e=>{f(e.target.files),e.target.value=``}})]}),t.length?/* @__PURE__ */ (0,A.jsx)(`ul`,{className:`ui-upload-list`,children:t.map(e=>{let t=e.status===`error`;return/* @__PURE__ */ (0,A.jsxs)(`li`,{className:M(`ui-upload-item`,t&&`is-error`),children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`file`,size:20,className:`ui-upload-icon`}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-upload-body`,children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-upload-row`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-upload-name`,children:e.name}),e.size?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-upload-size`,children:e.size}):null]}),t?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-upload-error`,role:`alert`,children:[e.error||w(`上傳失敗,請再試一次。`),i?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn`,onClick:()=>i(e),children:w(`重試`)}):null]}):/* @__PURE__ */ (0,A.jsx)(lb,{value:e.status===`done`?100:e.progress||0,"aria-label":w(`{name} 上傳進度`,{name:e.name})})]}),r?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-dialog-close`,"aria-label":w(`移除 {name}`,{name:e.name}),onClick:()=>r(e),children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`,size:16})}):null]},e.id??e.name)})}):null]})}function db({children:e,className:t}){return/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-formgrid`,t),children:e})}function fb(){let e=(e,t)=>/* @__PURE__ */ (0,A.jsx)(`marker`,{id:e,viewBox:`0 0 10 10`,refX:9,refY:5,markerWidth:7,markerHeight:7,orient:`auto-start-reverse`,children:/* @__PURE__ */ (0,A.jsx)(`path`,{d:`M0 0L10 5L0 10z`,className:M(`ui-graph-arrow`,t&&`is-accent`)})});return/* @__PURE__ */ (0,A.jsxs)(`defs`,{children:[e(`ui-arrow`,!1),e(`ui-arrow-accent`,!0)]})}let pb=[{type:`edge`,label:`確定的關係`},{type:`inferred`,label:`推測的關係`},{type:`external`,label:`外部項目`}];function mb({type:e}){return e===`weight`?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-graph-legend-sw`,children:[1.5,6].map(e=>/* @__PURE__ */ (0,A.jsx)(`svg`,{width:22,height:8,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(`line`,{x1:0,y1:4,x2:22,y2:4,className:`ui-graph-edge`,style:{strokeWidth:e}})},e))}):e===`external`||e===`node`?/* @__PURE__ */ (0,A.jsx)(`svg`,{width:22,height:14,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(`rect`,{x:1,y:1,width:20,height:12,rx:4,className:M(`ui-graph-node`,e===`external`&&`is-external`)})}):/* @__PURE__ */ (0,A.jsx)(`svg`,{width:28,height:8,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(`line`,{x1:0,y1:4,x2:28,y2:4,className:M(`ui-graph-edge`,e===`inferred`&&`is-inferred`,e===`declared`&&`is-declared`)})})}function hb({items:e=pb,className:t}){return/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-graph-legend`,t),children:e.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-graph-legend-item`,children:[/* @__PURE__ */ (0,A.jsx)(mb,{type:e.type}),e.text?/* @__PURE__ */ (0,A.jsx)(xv,{title:e.label,text:e.text,children:w(e.label)}):w(e.label)]},t))})}function gb({text:e,label:t,className:n}){let r=e??w(`AI 撰寫`);return/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-aimark`,n),"aria-hidden":`true`,children:r}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:t??w(`({v})`,{v:r})})]})}Fe(),ti(Pe);let _b=/^\s*<details\b[^>]*>/i,vb=/<(\/?)details\b[^>]*>/gi,yb=/<summary\b[^>]*>([\s\S]*?)<\/summary>/i,bb=/^\s*\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*$/i,xb={NOTE:`info`,TIP:`success`,IMPORTANT:`info`,WARNING:`warning`,CAUTION:`danger`},Sb=/^ {0,3}(`{3,}|~{3,})\s*([\w+#.-]*)/,Cb=/^ {0,3}(#{1,6})(?:\s+(.*?))?\s*#*\s*$/,wb=/^ {0,3}([-*_])(?:\s*\1){2,}\s*$/,Tb=/^( {0,3})([-*+]|\d{1,9}[.)])(\s+|$)(.*)$/,Eb=/^ {0,3}> ?(.*)$/,Db=/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/;function Ob(e){let t=e.trim();t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&!t.endsWith(`\\|`)&&(t=t.slice(0,-1));let n=[],r=``,i=!1;for(let e=0;e<t.length;e++){let a=t[e];a===`\\`&&t[e+1]===`|`?(r+=`|`,e++):a==="`"?(i=!i,r+=a):a===`|`&&!i?(n.push(r.trim()),r=``):r+=a}return n.push(r.trim()),n}let kb=e=>!e.trim(),Ab=e=>Sb.test(e)||Cb.test(e)||wb.test(e)||Eb.test(e)||Tb.test(e);function jb(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(kb(r)){n++;continue}if(_b.test(r)){let r=e.slice(n).join(`
83
- `);vb.lastIndex=0;let i=0,a=-1,o=r.length,s=r.length;for(let e=vb.exec(r);e;e=vb.exec(r))if(!e[1])i++===0&&(a=e.index+e[0].length);else if(--i===0){o=e.index,s=e.index+e[0].length;break}let c=r.slice(a,o),l=yb.exec(c);return l&&(c=c.slice(0,l.index)+c.slice(l.index+l[0].length)),t.push({t:`details`,summary:(l?.[1]??``).trim(),blocks:jb(c.split(`
84
- `))}),t.concat(jb(r.slice(s).split(`
85
- `)))}let i=Sb.exec(r);if(i){let r=i[1],a=[];for(n++;n<e.length&&!e[n].trim().startsWith(r);)a.push(e[n++]);n++,t.push({t:`code`,lang:i[2].toLowerCase(),code:a.join(`
86
- `)});continue}let a=Cb.exec(r);if(a){t.push({t:`h`,level:a[1].length,text:a[2]??``}),n++;continue}if(wb.test(r)){t.push({t:`hr`}),n++;continue}if(Eb.test(r)){let r=[];for(;n<e.length&&!kb(e[n])&&(Eb.test(e[n])||!Ab(e[n]));)r.push(Eb.exec(e[n])?.[1]??e[n]),n++;let i=r.length>0?bb.exec(r[0]):null;i?t.push({t:`alert`,tone:xb[i[1].toUpperCase()],blocks:jb(r.slice(1))}):t.push({t:`quote`,blocks:jb(r)});continue}let o=Tb.exec(r);if(o){let r=/\d/.test(o[2]),i=r?parseInt(o[2],10):1,a=[];for(;n<e.length;){let t=Tb.exec(e[n]);if(!t||/\d/.test(t[2])!==r)break;let i=t[1].length+t[2].length+Math.max(1,Math.min(t[3].length,4)),o=[t[4]];for(n++;n<e.length;){let t=e[n];if(kb(t)){let t=e[n+1];if(t!==void 0&&/^\s+/.test(t)&&t.search(/\S/)>=i){o.push(``),n++;continue}break}let r=t.search(/\S/);if(r>=i||r>=2&&Tb.test(t.trimStart()))o.push(t.slice(Math.min(r,i)));else if(!Ab(t)&&!Tb.test(t))o.push(t);else break;n++}if(a.push(jb(o)),n<e.length&&kb(e[n])){let t=e[n+1];if(t!==void 0&&Tb.test(t)&&/\d/.test(Tb.exec(t)?.[2]??``)===r){n++;continue}break}}t.push({t:`list`,ordered:r,start:i,items:a});continue}if(r.includes(`|`)&&n+1<e.length&&Db.test(e[n+1])&&e[n+1].includes(`-`)){let i=Ob(r),a=Ob(e[n+1]).map(e=>e.startsWith(`:`)&&e.endsWith(`:`)?`center`:e.endsWith(`:`)?`right`:e.startsWith(`:`)?`left`:null),o=[];for(n+=2;n<e.length&&!kb(e[n])&&e[n].includes(`|`);)o.push(Ob(e[n++]));t.push({t:`table`,head:i,align:a,rows:o});continue}let s=[r];for(n++;n<e.length&&!kb(e[n])&&!Ab(e[n]);)s.push(e[n++]);t.push({t:`p`,text:s.join(`
87
- `)})}return t}function Mb(e){let t=e.trim();if(!t)return;let n=/^([a-z][a-z0-9+.-]*):/i.exec(t);return n?[`http`,`https`,`mailto`].includes(n[1].toLowerCase())?t:void 0:t}let Nb=/^(?:\.{1,2}\/)?(?:[\w.-]+\/)*[\w.-]+\.[A-Za-z0-9]+(?::\d+(?:-\d+)?)?$/,Pb=e=>Nb.test(e)&&(e.includes(`/`)||/:\d/.test(e)),Fb=[`javascript`,`data`,`vbscript`],Ib=e=>({...e,seen:/* @__PURE__ */ new Set}),Lb=e=>({...e,seen:void 0}),Rb=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\u3000-\u303f\uff00-\uffef]/u;function zb(e,t){let n=null,r=[],i=``,a=()=>{i&&t.termRe&&t.terms&&t.seen?r.push(...Dv(i,Tv(i,t.terms,t.termRe,t.termsMark,t.seen),t.terms,t.k)):i&&r.push(i),i=``},o=0;for(;o<e.length;){let c=e[o];if(c===`\\`&&o+1<e.length&&/[\\`*_{}[\]()#+\-.!|<>~]/.test(e[o+1]))i+=e[o+1],o+=2;else if(c===`\\`&&e[o+1]===`
79
+ var t=f(),n=gu();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),vu=/* @__PURE__ */ s(((e,t)=>{t.exports=_u()})),yu=gu(),bu=vu();let xu=Oc(19)?wu:Tu;function Su(e,t,n,r,i){return xu(e,t,n,r,i)}function Cu(e,t,n,r,i){let a=y.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,yu.useSyncExternalStore)(e.subscribe,a,a)}Ei({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,i)||(t=!0,r.value=i)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=/* @__PURE__ */ new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,yu.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function wu(e,t,n,r,i){let a=Ti();if(!a)return Cu(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],s.store===e&&s.selector===t&&Object.is(s.a1,n)&&Object.is(s.a2,r)&&Object.is(s.a3,i)||(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.value=t(e.getSnapshot(),n,r,i))):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i)},a.syncHooks.push(s)),s.value}function Tu(e,t,n,r,i){return(0,bu.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var Eu=class{static create(e){return new this(e)}constructor(e){this.state=e,this.listeners=/* @__PURE__ */ new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return Su(this,e,t,n,r)}},Du=class extends Eu{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){y.useDebugValue(e);let n=this;X(()=>{n.state[e]!==t&&n.set(e,t)},[n,e,t])}useSyncedValueWithCleanup(e,t){let n=this;X(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this,n=Object.values(e);X(()=>{t.update(e)},[t,...n])}useControlledProp(e,t){y.useDebugValue(e);let n=this,r=t!==void 0;X(()=>{r&&!Object.is(n.state[e],t)&&n.setState({...n.state,[e]:t})},[n,e,t,r])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return y.useDebugValue(e),Su(this,this.selectors[e],t,n,r)}useContextCallback(e,t){y.useDebugValue(e);let n=$(t??Ai);this.context[e]=n}useStateSetter(e){let t=y.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}};let Ou={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId};var ku=class extends Du{constructor(e){let{syncOnly:t,nested:n,onOpenChange:r,triggerElements:i,...a}=e;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:dl(),nested:n,triggerElements:i},Ou),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&oa(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);let n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit(`openchange`,n)};setOpen=(e,t)=>{this.syncOnly||this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function Au(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new ku({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,openedWithoutTrigger:!1,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:Mi,inactiveTriggerProps:Mi,popupProps:Mi}}let ju=e=>e.triggerIdProp??e.activeTriggerId,Mu=e=>e.openProp??e.open,Nu=e=>(e.popupElement?.id??e.floatingId)||void 0;function Pu(e,t){return t!==void 0&&Mu(e)&&ju(e)===t}function Fu(e,t){return Pu(e,t)?!0:t!==void 0&&Mu(e)&&ju(e)==null&&!e.openedWithoutTrigger&&e.triggerCount===1}let Iu={open:Mu,mounted:e=>e.mounted,transitionStatus:e=>Mu(e)&&!e.mounted?`starting`:e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:ju,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:Nu,isTriggerActive:(e,t)=>t!==void 0&&ju(e)===t,isOpenedByTrigger:(e,t)=>Pu(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&ju(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>Fu(e,t)?Nu(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function Lu(e){let t=y.useCallback(t=>e===void 0?Ai:e.subscribeStore(t),[e]),n=y.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,yu.useSyncExternalStore)(t,n,()=>e?.serverStore)}function Ru(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=Dc(),a=hl()!=null,o=Si(()=>new ku({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new mu,floatingId:i,syncOnly:!1,nested:a})).current;return X(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=fa(r.reference)?r.reference:null),r.floating!==void 0&&(e.floatingElement=r.floating),o.update(e)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}let zu=Yi&&Zi;function Bu(e,t={}){let{enabled:n=!0,delay:r}=t,{events:i,dataRef:a}=e.context,o=y.useRef(!1),s=y.useRef(null),c=y.useRef(!0),l=zi();y.useEffect(()=>{let t=e.select(`domReferenceElement`);if(!n)return;let r=la(t);function i(){let t=e.select(`domReferenceElement`);!e.select(`open`)&&pa(t)&&t===Ma(Zo(t))&&(o.current=!0,s.current=t)}function a(){c.current=!0}function l(){c.current=!1}return Po(No(r,`blur`,i),zu&&No(r,`keydown`,a,!0),zu&&No(r,`pointerdown`,l,!0))},[e,n]),y.useEffect(()=>{if(!n)return;function t(t){if(t.reason===`trigger-press`||t.reason===`escape-key`){let t=e.select(`domReferenceElement`);fa(t)&&(s.current=t,o.current=!0)}}return i.on(`openchange`,t),()=>{i.off(`openchange`,t)}},[i,n,e]);let u=y.useMemo(()=>{function t(){o.current=!1,s.current=null}return{onMouseLeave(){t()},onFocus(n){let i=n.currentTarget;if(o.current){if(s.current===i)return;t()}let a=Pa(n.nativeEvent);if(fa(a)){if(zu&&!n.relatedTarget){if(!c.current&&!to(a))return}else if(!io(a))return}let u=Qa(n.relatedTarget,e.context.triggerElements),{nativeEvent:d,currentTarget:f}=n;e.select(`open`)&&u||!r?e.setOpen(!0,Q(go,d,f)):l.start(r,()=>{o.current||e.setOpen(!0,Q(go,d,f))})},onBlur(n){t();let r=n.relatedTarget,i=n.nativeEvent,o=fa(r)&&r.hasAttribute(lc(`focus-guard`))&&r.getAttribute(`data-type`)===`outside`;l.start(0,()=>{let t=e.select(`domReferenceElement`),n=Ma(Zo(t));!r&&n===t||Z(a.current.floatingContext?.refs.floating.current,n)||Z(t,n)||o||Qa(r??n,e.context.triggerElements)||e.setOpen(!1,Q(go,i))})}}},[a,r,e,l]);return y.useMemo(()=>n?{reference:u,trigger:u}:{},[n,u])}var Vu=class e{pointerType=void 0;interactedInside=!1;handler=void 0;blockMouseMove=!0;performedPointerEventsMutation=!1;pointerEventsScopeElement=null;pointerEventsReferenceElement=null;pointerEventsFloatingElement=null;restTimeoutPending=!1;openChangeTimeout=new Ri;restTimeout=new Ri;handleCloseOptions=void 0;static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose};let Hu=/* @__PURE__ */ new WeakMap;function Uu(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&Hu.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),Hu.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function Wu(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=Hu.get(n);a&&a!==e&&Uu(a),Uu(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,Hu.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function Gu(e){let t=e.context.dataRef.current,n=Si(()=>t.hoverInteractionState??Vu.create()).current;return t.hoverInteractionState||=n,Li(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function Ku(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=e.useState(`open`),o=e.useState(`floatingElement`),s=e.useState(`domReferenceElement`),{dataRef:c}=e.context,l=gl(),u=hl(),d=Gu(e),f=zi(),p=$(()=>lo(c.current.openEvent?.type,d.interactedInside)),m=$(()=>uo(c.current.openEvent?.type)),h=$(()=>{Uu(d)});X(()=>{a||(d.pointerType=void 0,d.restTimeoutPending=!1,d.interactedInside=!1,h())},[a,d,h]),y.useEffect(()=>h,[h]),X(()=>{if(n&&a&&d.handleCloseOptions?.blockPointerEvents&&m()&&fa(s)&&o){let e=s,t=o,n=Zo(o),r=l?.nodesRef.current.find(e=>e.id===u)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=d.pointerEventsScopeElement===t?null:d.pointerEventsScopeElement,a=r===t?null:r,c=d.handleCloseOptions?.getScope?.()??i??a??Na(e,`[data-rootownerid]`)??n.body;return Wu(d,{scopeElement:c,referenceElement:e,floatingElement:t}),()=>{h()}}},[n,a,s,o,d,m,l,u,h]),y.useEffect(()=>{if(!n)return;function t(){return!!(l&&u&&sc(l.nodesRef.current,u).length>0)}function a(t){let n=so(r,`close`,d.pointerType),i=()=>{e.setOpen(!1,Q(ho,t)),l?.events.emit(`floating.closed`,t)};n?d.openChangeTimeout.start(n,i):(d.openChangeTimeout.clear(),i())}function s(e){let t=Pa(e);no(t)?d.interactedInside=Na(t,`[aria-haspopup]`)!=null:d.interactedInside=!1}function g(){d.openChangeTimeout.clear(),f.clear(),l?.events.off(`floating.closed`,v),h()}function _(n){if(t()&&l){l.events.on(`floating.closed`,v);return}if(Qa(n.relatedTarget,e.context.triggerElements))return;let r=c.current.floatingContext?.nodeId??i,o=n.relatedTarget;l&&r&&fa(o)&&sc(l.nodesRef.current,r,!1).some(e=>Z(e.context?.elements.floating,o))||(d.handler?d.handler(n):(h(),m()&&!p()&&a(n)))}function v(n){l&&u&&!t()&&f.start(0,()=>{l.events.off(`floating.closed`,v),e.setOpen(!1,Q(ho,n)),l.events.emit(`floating.closed`,n)})}let y=o;return Po(y&&No(y,`mouseenter`,g),y&&No(y,`mouseleave`,_),y&&No(y,`pointerdown`,s,!0),()=>{l?.events.off(`floating.closed`,v)})},[n,o,e,c,r,i,m,p,h,d,l,u,f])}let qu={current:null};function Ju(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=qu,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:f,shouldOpen:p,guardStaleOpen:m=!1}=t,{dataRef:h,events:g}=e.context,_=gl(l),v=Gu(e),x=y.useRef(!1),S=Vo(i),C=Vo(r),w=Vo(o),T=Vo(n),E=Vo(p),D=Vo(f),O=$(()=>lo(h.current.openEvent?.type,v.interactedInside)),k=$(()=>E.current?.()!==!1),A=$((t,n,r)=>{let i=e.context.triggerElements;if(i.hasElement(n))return!t||!Z(t,n);if(!fa(r))return!1;let a=r;return i.hasMatchingElement(e=>Z(e,a))&&(!t||!Z(t,a))}),j=$(()=>{v.handler&&=(Zo(e.select(`domReferenceElement`)).removeEventListener(`mousemove`,v.handler),void 0)}),M=$(()=>{Uu(v)});return u&&(v.handleCloseOptions=i?.__options),y.useEffect(()=>j,[j]),y.useEffect(()=>{if(!n)return;function e(e){e.open?x.current=!1:(x.current=e.reason===ho,j(),v.openChangeTimeout.clear(),v.restTimeout.clear(),v.blockMouseMove=!0,v.restTimeoutPending=!1)}return g.on(`openchange`,e),()=>{g.off(`openchange`,e)}},[n,g,v,j]),y.useEffect(()=>{if(!n)return;function t(t,n=!0){let r=so(C.current,`close`,v.pointerType);r?v.openChangeTimeout.start(r,()=>{e.setOpen(!1,Q(ho,t)),_?.events.emit(`floating.closed`,t)}):n&&(v.openChangeTimeout.clear(),e.setOpen(!1,Q(ho,t)),_?.events.emit(`floating.closed`,t))}let r=c.current??(u?e.select(`domReferenceElement`):null);if(!fa(r))return;function i(t){if(v.openChangeTimeout.clear(),v.blockMouseMove=!1,a&&!aa(v.pointerType))return;let n=co(w.current),r=so(C.current,`open`,v.pointerType),i=Pa(t),o=t.currentTarget??null,s=e.select(`domReferenceElement`),c=o;if(fa(i)&&!e.context.triggerElements.hasElement(i)){for(let t of e.context.triggerElements.elements())if(Z(t,i)){c=t;break}}fa(o)&&fa(s)&&!e.context.triggerElements.hasElement(o)&&Z(o,s)&&(c=s);let l=c!=null&&A(s,c,i),u=e.select(`open`),d=D.current?.()??e.select(`transitionStatus`)===`ending`,f=!u&&d&&x.current,p=!l&&fa(c)&&fa(s)&&Z(s,c)&&f,m=n>0&&!r,h=l&&(u||f)||p,g=!u||l;h?k()&&e.setOpen(!0,Q(ho,t,c)):m||(r?v.openChangeTimeout.start(r,()=>{g&&k()&&e.setOpen(!0,Q(ho,t,c))}):g&&k()&&e.setOpen(!0,Q(ho,t,c)))}function o(n){if(O()){M();return}j();let r=Zo(e.select(`domReferenceElement`));v.restTimeout.clear(),v.restTimeoutPending=!1;let i=h.current.floatingContext??d?.();if(!Qa(n.relatedTarget,e.context.triggerElements)){if(S.current&&i){e.select(`open`)||v.openChangeTimeout.clear();let a=c.current;v.handler=S.current({...i,tree:_,x:n.clientX,y:n.clientY,onClose(){M(),j(),T.current&&!O()&&a===e.select(`domReferenceElement`)&&t(n,!0)}}),r.addEventListener(`mousemove`,v.handler),v.handler(n)}else v.pointerType===`touch`&&Z(e.select(`floatingElement`),n.relatedTarget)||t(n)}}function l(e){Z(r,e.relatedTarget)||(v.openChangeTimeout.clear(),v.restTimeout.clear(),v.restTimeoutPending=!1)}let f=m?No(r,`mouseout`,l):void 0;return s?Po(No(r,`mousemove`,i,{once:!0}),No(r,`mouseenter`,i),No(r,`mouseleave`,o),f):Po(No(r,`mouseenter`,i),No(r,`mouseleave`,o),f)},[j,M,h,C,e,n,S,v,u,A,O,a,s,w,c,_,T,d,D,k,m]),y.useMemo(()=>{if(!n)return;function t(e){v.pointerType=e.pointerType}return{onPointerDown:t,onPointerEnter:t,onMouseMove(t){let{nativeEvent:n}=t,r=t.currentTarget,i=e.select(`domReferenceElement`),o=e.select(`open`),s=A(i,r,t.target);if(a&&!aa(v.pointerType))return;if(o&&s&&v.handleCloseOptions?.blockPointerEvents){let t=e.select(`floatingElement`);if(t){let e=v.handleCloseOptions?.getScope?.()??r.ownerDocument.body;Wu(v,{scopeElement:e,referenceElement:r,floatingElement:t})}}let c=co(w.current);if(o&&!s||c===0||!s&&v.restTimeoutPending&&t.movementX**2+t.movementY**2<2)return;v.restTimeout.clear();function l(){if(v.restTimeoutPending=!1,O())return;let t=e.select(`open`);!v.blockMouseMove&&(!t||s)&&k()&&e.setOpen(!0,Q(ho,n,r))}v.pointerType===`touch`?b.flushSync(()=>{l()}):s&&o?l():(v.restTimeoutPending=!0,v.restTimeout.start(c,l))}}},[n,v,O,A,a,e,w,k])}function Yu(e){return Zi&&e.movementX===0&&e.movementY===0}function Xu(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function Zu(e,t){return Xu(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function Qu(e,t,n){return Xu(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function $u(e,t,n){return Xu(t,n?e===Fa:e===Ia,e===`ArrowDown`)}function ed(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===`Escape`:Xu(t,n?e===Ia:e===Fa,e===`ArrowUp`)}function td(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:l=!1,rtl:u=!1,virtual:d=!1,focusItemOnOpen:f=`auto`,focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:h=void 0,orientation:g=`vertical`,triggerOrientation:_=g,parentOrientation:v,id:b,resetOnPointerLeave:x=!0,externalTree:S,nestedReturnFocusRef:C,grid:w}=t,T=w!=null,E=e.useState(`open`),D=e.useState(`floatingElement`),O=e.useState(`domReferenceElement`),k=e.context.dataRef,A=ao(D),j=ro(O),M=Vo(A),N=hl(),P=gl(S),F=y.useRef(f),I=y.useRef(o??-1),L=y.useRef(null),R=y.useRef(!0),z=$(e=>{i(I.current===-1?null:I.current,e)}),B=y.useRef(!!D),V=y.useRef(E),H=y.useRef(!1),U=y.useRef(!1),ee=y.useRef(null),te=Vo(h),ne=Vo(E),W=Vo(o),re=Vo(x),ie=Xo(),G=Xo(),K=$(()=>{ie.cancel();function e(e){d||(ee.current=dc(e,{sync:H.current,preventScroll:!0}))}let t=n.current[I.current],r=U.current;t&&e(t),(H.current?e=>e():e=>ie.request(e))(()=>{let i=n.current[I.current]||t;i&&(t||e(i),le&&(r||!R.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});X(()=>{k.current.orientation=g},[k,g]),X(()=>{E||(L.current=null),E&&f===`auto`||(F.current=f)},[E,f]),X(()=>{a&&(E&&D?(I.current=o??-1,F.current&&o!=null&&(U.current=!0,z())):B.current&&(I.current=-1,z()))},[a,E,D,o,z]),X(()=>{if(a){if(!E)H.current=!1;else if(D){if(r==null){if(H.current=!1,W.current!=null)return;if(B.current&&(I.current=-1,K()),(!V.current||!B.current)&&F.current&&(L.current!=null||F.current===!0&&L.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>G.request(e):queueMicrotask)(t),e+=1):(I.current=L.current==null||Qu(L.current,_,u)||l?js(n):Ms(n),L.current=null,z())};t()}}else As(n.current,r)||(I.current=r,K(),U.current=!1)}}},[a,E,D,r,W,l,n,_,u,z,K,G]),X(()=>{if(!a||D||!P||d||!B.current)return;let e=P.nodesRef.current,t=e.find(e=>e.id===N)?.context?.elements.floating,n=Ma(Zo(O??t??null)),r=e.some(e=>e.context&&Z(e.context.elements.floating,n));t&&!r&&R.current&&t.focus({preventScroll:!0})},[a,D,O,P,N,d]),X(()=>{V.current=E,B.current=!!D});let q=r!=null,ae=$(e=>{if(!ne.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(I.current!==t||r!==t)&&(I.current=t,z(e))}),oe=$(()=>v??P?.nodesRef.current.find(e=>e.id===N)?.context?.dataRef?.current.orientation),se=$(()=>js(n,te.current)),ce=$(t=>{if(R.current=!1,H.current=!0,t.which===229||!ne.current&&t.currentTarget===M.current)return;if(l&&ed(t.key,g,u,T)){Zu(t.key,oe())||ta(t),e.setOpen(!1,Q(wo,t.nativeEvent));let n=C?.current??O;pa(n)&&n.focus();return}r!=null&&r!==I.current&&!As(n.current,r)&&(I.current=r);let i=I.current,a=js(n,h),o=Ms(n,h);if(j||(t.key===`Home`&&(ta(t),I.current=a,z(t)),t.key===`End`&&(ta(t),I.current=o,z(t))),w!=null){let e=w(t,I.current,n,g,c,u,h,a,o);if(e!=null&&e!==I.current&&(I.current=e,z(t)),g===`both`)return}if(Zu(t.key,g)){ta(t);let e=Ma(t.currentTarget.ownerDocument);if(E&&!d&&Z(t.currentTarget,e)&&!n.current.some(t=>t!=null&&Z(t,e))){I.current=Qu(t.key,g,u)?a:o,z(t),r===I.current&&K();return}let{index:l,wrapped:f}=Ns(n.current,i,{decrement:!Qu(t.key,g,u),loopFocus:c,allowEscape:s,disabledIndices:h,minIndex:a,maxIndex:o});f&&(H.current=!1),I.current=l,z(t)}}),le=y.useMemo(()=>({onFocus(e){H.current=!0,ae(e)},onClick({currentTarget:e}){d||e.focus({preventScroll:!0})},onMouseMove(e){Yu(e)||(H.current=!0,U.current=!1,p&&ae(e))},onPointerLeave(e){if(!ne.current||!R.current||e.pointerType===`touch`)return;H.current=!0;let t=e.relatedTarget;if(p&&!n.current.includes(t)&&re.current&&(ee.current?.(),ee.current=null,I.current=-1,z(e),!d)){let e=M.current,t=Ma(Zo(e));e&&Z(e,t)&&e.focus({preventScroll:!0})}}}),[ae,ne,M,p,n,z,re,d]),J=y.useMemo(()=>d&&E&&q&&{"aria-activedescendant":`${b}-${r}`},[d,E,q,b,r]),ue=y.useMemo(()=>({...j?{}:J,onKeyDown(t){if(t.key===`Tab`&&t.shiftKey&&E&&!d){let n=Pa(t.nativeEvent);if(n&&!Z(M.current,n))return;ta(t);let r=Q(So,t.nativeEvent);e.setOpen(!1,r);let i=C?.current??O;!r.isCanceled&&pa(i)&&i.focus()}else ce(t)},onPointerMove(e){Yu(e)||(R.current=!0)}}),[J,ce,M,j,e,E,d,O,C]),de=y.useMemo(()=>{function t(t){e.setOpen(!0,Q(wo,t.nativeEvent,t.currentTarget))}function n(e){f===`auto`&&ra(e.nativeEvent)&&(F.current=!d)}function r(e){F.current=f,f===`auto`&&ia(e.nativeEvent)&&(F.current=!0)}return{onKeyDown(n){let r=e.select(`open`);R.current=!1;let i=n.key.startsWith(`Arrow`),a=$u(n.key,oe(),u),o=Zu(n.key,r?g:_),s=(l?a:o)||n.key===`Enter`||n.key.trim()===``;if(d&&r&&(!l||to(n.currentTarget)))return ce(n);if(r||m||!i){if(s){let e=Zu(n.key,oe());L.current=l&&e?null:n.key}l?a&&(ta(n),r?(I.current=se(),z(n),d&&M.current?.focus()):t(n)):o&&(W.current!=null&&(I.current=W.current),ta(n),!r&&m?t(n):ce(n),r&&z(n))}},onFocus(t){t.target===t.currentTarget&&e.select(`open`)&&!d&&(I.current=-1,z(t))},onPointerDown:r,onPointerEnter:r,onMouseDown:n,onClick:n}},[ce,f,se,l,z,e,m,g,_,oe,u,W,d,M]),fe=y.useMemo(()=>({...J,...de}),[J,de]);return y.useMemo(()=>a?{reference:fe,floating:ue,item:le,trigger:de}:{},[a,fe,ue,de,le])}function nd(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=$(s),f=e.useState(`open`),p=zi(),m=y.useRef(``),h=y.useRef(u??i??-1),g=y.useRef(null),_=$(e=>{function t(e){return r?.current[e]}function s(e){let n=t(e);return n&&!Rs(n)||n?.matches(`:disabled`)?!1:o==null||!Is(ji,e,o)}function c(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(e[n]?.toLowerCase().startsWith(i)&&s(n))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(ta(e),d?.(!0)),m.current.length>0&&m.current[0]!==` `&&c(_,m.current)===-1&&e.key!==` `&&d?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(ta(e),d?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&s(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,d?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=c(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,d?.(!1)):(a?.(b,e),g.current=b)}),v=$(t=>{let n=t.relatedTarget,r=e.select(`domReferenceElement`),i=e.select(`floatingElement`);Z(r,n)||Z(i,n)||(p.clear(),m.current=``,h.current=g.current,d?.(!1))});X(()=>{(f||u===null)&&(p.clear(),g.current=null,m.current!==``&&(m.current=``,d?.(!1)))},[f,u,p,d]);let b=y.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return y.useMemo(()=>c?{reference:b,floating:b}:{},[c,b])}let rd=.5;function id(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function ad(e,t,n,r,i,a,o,s,c,l){let u=!1;return id(e,t,n,r,i,a)&&(u=!u),id(e,t,i,a,o,s)&&(u=!u),id(e,t,o,s,c,l)&&(u=!u),id(e,t,c,l,n,r)&&(u=!u),u}function od(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function sd(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function cd(e={}){let{blockPointerEvents:t=!1}=e,n=new Ri,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*.010000000000000002;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=Pa(r),g=r.type===`mouseleave`,_=Z(u,h),v=Z(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&fa(r.relatedTarget)&&Z(u,r.relatedTarget))return;function y(){return!!(s&&sc(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=sd(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=sd(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=sd(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=sd(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!od(d,f,x)||!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?rd/2:rd*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+rd+1,o=C||T?S.bottom-rd:S.top,s=C?T?S.bottom-rd:S.top:S.bottom-rd;M=ad(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?rd/2:rd*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-rd,o=C||T?S.top+rd:S.bottom,s=C?T?S.top+rd:S.bottom:S.top+rd;M=ad(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?rd/2:rd*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+rd+1,o=w||E?S.right-rd:S.left,s=w?E?S.right-rd:S.left:S.right-rd;M=ad(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?rd/2:rd*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-rd,o=w||E?S.left+rd:S.right,s=w?E?S.left+rd:S.right:S.left+rd;M=ad(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}function ld(e,t,n){let{reference:r,floating:i}=e,a=ms(t),o=hs(t),s=ps(o),c=us(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=ds(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function ud(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=ls(t,e),p=Ds(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Os(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Os(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}let dd=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:ud},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=ld(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<50&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=ld(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},fd=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=ls(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=us(r),_=ms(o),v=us(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Ts(o)]:_s(o)),x=p!==`none`;!d&&x&&b.push(...ws(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=gs(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===ms(t)||T.every(e=>ms(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=ms(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},pd=/*#__PURE__*/ new Set([`left`,`top`]);async function md(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=us(n),s=ds(n),c=ms(n)===`y`,l=pd.has(o)?-1:1,u=a&&c?-1:1,d=ls(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}let hd=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await md(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},gd=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=ls(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=ms(i),p=fs(f),m=u[p],h=u[f],g=(e,t)=>cs(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},_d=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=ls(e,t),u={x:n,y:r},d=ms(i),f=fs(d),p=u[f],m=u[d],h=ls(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=pd.has(us(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},vd=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=ls(e,t),c=await i.detectOverflow(t,s),l=us(n),u=ds(n),d=ms(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=ns(p-c[m],g),y=ns(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*rs(c.left,c.right):S=p-2*rs(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function yd(e){let t=Ea(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=pa(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=is(n)!==a||is(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function bd(e){return fa(e)?e:e.contextElement}function xd(e){let t=bd(e);if(!pa(t))return os(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=yd(t),o=(a?is(n.width):n.width)/r,s=(a?is(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}let Sd=/*#__PURE__*/ os(0);function Cd(e){let t=la(e);return!wa()||!t.visualViewport?Sd:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function wd(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===la(e)}function Td(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=bd(e),o=os(1);t&&(r?fa(r)&&(o=xd(r)):o=xd(e));let s=wd(a,n,r)?Cd(a):os(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=la(a),t=fa(r)?la(r):r,n=e,i=ja(n);for(;i&&t!==n;){let e=xd(i),t=i.getBoundingClientRect(),r=Ea(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=la(i),i=ja(n)}}return Os({width:u,height:d,x:c,y:l})}function Ed(e,t){let n=Da(e).scrollLeft;return t?t.left+n:Td(ua(e)).left+n}function Dd(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Ed(e,n),y:n.top+t.scrollTop}}function Od(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=ua(r),s=t?_a(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=os(1),u=os(0),d=pa(r);if((d||!a)&&((ca(r)!==`body`||ha(o))&&(c=Da(r)),d)){let e=Td(r);l=xd(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Dd(o,c):os(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function kd(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Ad(e){let t=Da(e),n=e.ownerDocument.body,r=rs(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=rs(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Ed(e),o=-t.scrollTop;return Ea(n).direction===`rtl`&&(a+=rs(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}function jd(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=la(e),a=ua(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!wa()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Ed(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=25&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Md(e,t){let n=Td(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=xd(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Nd(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=jd(e,n,t);else if(t===`document`)r=Ad(ua(e));else if(fa(t))r=Md(t,n);else{let n=Cd(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Os(r)}function Pd(e,t){let n=t.get(e);if(n)return n;let r=Aa(e,[],!1).filter(e=>fa(e)&&ca(e)!==`body`),i=null,a=Ea(e).position===`fixed`,o=a?Oa(e):e;for(;fa(o)&&!Ta(o);){let e=Ea(o),t=Sa(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Oa(o)}return t.set(e,r),r}function Fd(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?_a(t)?[]:Pd(t,this._c):[].concat(n),r],o=Nd(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Nd(t,a[e],i);s=rs(n.top,s),c=ns(n.right,c),l=ns(n.bottom,l),u=rs(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Id(e){let{width:t,height:n}=yd(e);return{width:t,height:n}}function Ld(e,t,n){let r=pa(t),i=ua(t),a=n===`fixed`,o=Td(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=os(0);if((r||!a)&&((ca(t)!==`body`||ha(i))&&(s=Da(t)),r)){let e=Td(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=Ed(i));let l=i&&!r&&!a?Dd(i,s):os(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Rd(e){return Ea(e).position===`static`}function zd(e,t){if(!pa(e)||Ea(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return ua(e)===n&&(n=n.ownerDocument.body),n}function Bd(e,t){let n=la(e);if(_a(e))return n;if(!pa(e)){let t=Oa(e);for(;t&&!Ta(t);){if(fa(t)&&!Rd(t))return t;t=Oa(t)}return n}let r=zd(e,t);for(;r&&ga(r)&&Rd(r);)r=zd(r,t);return r&&Ta(r)&&Rd(r)&&!Sa(r)?n:r||Ca(e)||n}let Vd=async function(e){let t=this.getOffsetParent||Bd,n=this.getDimensions,r=await n(e.floating);return{reference:Ld(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Hd(e){return Ea(e).direction===`rtl`}let Ud={convertOffsetParentRelativeRectToViewportRelativeRect:Od,getDocumentElement:ua,getClippingRect:Fd,getOffsetParent:Bd,getElementRects:Vd,getClientRects:kd,getDimensions:Id,getScale:xd,isElement:fa,isRTL:Hd};function Wd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Gd(e,t,n){let r=null,i,a=ua(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=as(d),h=as(a.clientWidth-(u+f)),g=as(a.clientHeight-(d+p)),_=as(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:rs(0,ns(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Wd(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=la(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Kd(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=bd(e),u=i||a?[...l?Aa(l):[],...t?Aa(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Gd(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Td(e):null;c&&g();function g(){let t=Td(e);h&&!Wd(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}let qd=hd,Jd=gd,Yd=fd,Xd=vd,Zd=_d,Qd=(e,t,n)=>{let r=/* @__PURE__ */ new Map,i=n??{},a={...Ud,...i.platform,_c:r};return dd(e,t,{...i,platform:a})};var $d=typeof document<`u`?y.useLayoutEffect:function(){};function ef(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!ef(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!ef(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function tf(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function nf(e,t){let n=tf(e);return Math.round(t*n)/n}function rf(e){let t=y.useRef(e);return $d(()=>{t.current=e}),t}function af(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=y.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=y.useState(r);ef(f,r)||p(r);let[m,h]=y.useState(null),[g,_]=y.useState(null),v=y.useCallback(e=>{e!==w.current&&(w.current=e,h(e))},[]),x=y.useCallback(e=>{e!==T.current&&(T.current=e,_(e))},[]),S=a||m,C=o||g,w=y.useRef(null),T=y.useRef(null),E=y.useRef(u),D=c!=null,O=rf(c),k=rf(i),A=rf(l),j=y.useCallback(()=>{if(!w.current||!T.current)return;let e={placement:t,strategy:n,middleware:f};k.current&&(e.platform=k.current),Qd(w.current,T.current,e).then(e=>{let t={...e,isPositioned:A.current!==!1};M.current&&!ef(E.current,t)&&(E.current=t,b.flushSync(()=>{d(t)}))})},[f,t,n,k,A]);$d(()=>{l===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let M=y.useRef(!1);$d(()=>(M.current=!0,()=>{M.current=!1}),[]),$d(()=>{if(S&&(w.current=S),C&&(T.current=C),S&&C){if(O.current)return O.current(S,C,j);j()}},[S,C,j,O,D]);let N=y.useMemo(()=>({reference:w,floating:T,setReference:v,setFloating:x}),[v,x]),P=y.useMemo(()=>({reference:S,floating:C}),[S,C]),F=y.useMemo(()=>{let e={position:n,left:0,top:0};if(!P.floating)return e;let t=nf(P.floating,u.x),r=nf(P.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...tf(P.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,P.floating,u.x,u.y]);return y.useMemo(()=>({...u,update:j,refs:N,elements:P,floatingStyles:F}),[u,j,N,P,F])}let of=(e,t)=>{let n=qd(e);return{name:n.name,fn:n.fn,options:[e,t]}},sf=(e,t)=>{let n=Jd(e);return{name:n.name,fn:n.fn,options:[e,t]}},cf=(e,t)=>({fn:Zd(e).fn,options:[e,t]}),lf=(e,t)=>{let n=Yd(e);return{name:n.name,fn:n.fn,options:[e,t]}},uf=(e,t)=>{let n=Xd(e);return{name:n.name,fn:n.fn,options:[e,t]}},df={...Iu,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,appliedTriggerProps:(e,t)=>t?e.activeTriggerProps:void 0,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin};var ff=class extends Du{constructor(e,t,n){let r=new mu;super(pf(e,r,t,n),mf(r),df)}setOpen=(e,t)=>{cu(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,Q(mo,e))}};function pf(e,t,n,r=!1){return{...Au(t,n,r),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:`none`,disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e}}function mf(e){return{popupRef:/*#__PURE__*/ y.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}let hf=Di(function(e){let{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:a=`none`,actionsRef:o,onOpenChange:s,onOpenChangeComplete:c,handle:l,triggerId:u,defaultTriggerId:d=null,children:f}=e,p=nu((e,t)=>new ff({open:n,openProp:r,activeTriggerId:d,triggerIdProp:u},e,t));p.useControlledProp(`openProp`,r),p.useControlledProp(`triggerIdProp`,u),p.useContextCallback(`onOpenChange`,s),p.useContextCallback(`onOpenChangeComplete`,c);let m=p.useState(`open`),h=!t&&m,g=p.useState(`activeTriggerId`),_=p.useState(`mounted`),v=p.useState(`payload`);p.useSyncedValues({trackCursorAxis:a,disableHoverablePopup:i,disabled:t}),uu(p,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:b,transitionStatus:x}=du(h,p),S=p.useState(`isInstantPhase`),C=p.useState(`instantType`),w=p.useState(`lastOpenChangeReason`),T=y.useRef(null);X(()=>{m&&t&&p.setOpen(!1,Q(`disabled`))},[m,t,p]),X(()=>{x===`ending`&&w===`none`||x!==`ending`&&S?(C!==`delay`&&(T.current=C),p.set(`instantType`,`delay`)):T.current!==null&&(p.set(`instantType`,T.current),T.current=null)},[x,S,w,C,p]),X(()=>{h&&(g??p.set(`payload`,void 0))},[p,g,h]),y.useImperativeHandle(o,()=>({unmount:b,close:()=>p.setOpen(!1,Q(ko))}),[b,p]);let E=h||_||!t&&a!==`none`;return/*#__PURE__*/ (0,A.jsxs)(Fi.Provider,{value:p,children:[l&&/*#__PURE__*/ (0,A.jsx)(ru,{handle:l,store:p}),E&&/*#__PURE__*/ (0,A.jsx)(gf,{store:p,disabled:t,trackCursorAxis:a}),typeof f==`function`?f({payload:v}):f]})});function gf({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=Fl(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=Ml(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=y.useMemo(()=>Fc(a.reference,i.reference),[a.reference,i.reference]);return fu(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??Mi}),null}function _f(e){return Dc(e,`base-ui`)}let vf=/*#__PURE__*/ y.createContext(void 0);function yf(){return y.useContext(vf)}let bf=`data-base-ui-tooltip-trigger`;function xf(e){let t=Pa(e);return fa(t)?t:null}let Sf=Oi(function(e,t){let{render:n,className:r,style:i,handle:a,payload:o,disabled:s,delay:c,closeOnClick:l=!0,closeDelay:u,id:d,...f}=e,p=Ii(!0),m=Lu(a)??p;if(!m)throw Error(Pi(82));let h=_f(d),g=m.useState(`isTriggerActive`,h),_=m.useState(`isOpenedByTrigger`,h),v=m.useState(`floatingRootContext`),b=y.useRef(null),x=u??0,{registerTrigger:S,isMountedByThisTrigger:C}=lu(h,b,m,{payload:o,closeOnClick:l,closeDelay:x}),w=yf(),{activeIdRef:T,delayRef:E,isInstantPhase:D,hasProvider:O}=Mo(v,{open:_}),k=Gu(v);m.useSyncedValue(`isInstantPhase`,D);let A=m.useState(`disabled`),j=s??A,M=Vo(j),N=m.useState(`trackCursorAxis`),P=m.useState(`disableHoverablePopup`),F=y.useRef(!1),I=zi(),L=y.useRef(void 0);function R(){return O&&T.current!=null?0:c??w??600}function z(e){let t=b.current;if(!t||!e)return!1;let n=Na(e,`[${bf}]`);return n!==null&&n!==t&&Z(t,n)}function B(e){let t=z(e);return F.current=t,t&&(k.openChangeTimeout.clear(),k.restTimeout.clear(),k.restTimeoutPending=!1,I.clear()),t}let V=Ju(v,{enabled:!j,mouseOnly:!0,move:!1,handleClose:!P&&N!==`both`?cd():null,restMs:R,delay(){return u==null&&O?{close:so(E.current,`close`)}:{close:x}},triggerElementRef:b,isActiveTrigger:g,isClosing:()=>m.select(`transitionStatus`)===`ending`,shouldOpen(){return!F.current}}),H=Bu(v,{enabled:!j}).reference,U=e=>{let t=F.current,n=xf(e),r=B(n),i=b.current,a=i&&n&&Z(i,n);if(r&&m.select(`open`)&&m.select(`lastOpenChangeReason`)===`trigger-hover`)m.setOpen(!1,Q(ho,e));else if(t&&!r&&a&&!M.current&&!m.select(`open`)&&i&&aa(L.current)){let t=()=>{F.current||M.current||m.select(`open`)||m.setOpen(!0,Q(ho,e,i))},n=R();n===0?(I.clear(),t()):I.start(n,t)}},ee=m.useState(`appliedTriggerProps`,C||N!==`none`);return Jc(`button`,e,{state:{open:_},ref:[t,S,b],props:[V,H,ee,{onMouseOver(e){U(e.nativeEvent)},onFocus(e){z(xf(e.nativeEvent))&&e.preventBaseUIHandler()},onMouseLeave(){F.current=!1,I.clear(),L.current=void 0},onPointerEnter(e){L.current=e.pointerType},onPointerDown(e){L.current=e.pointerType,m.set(`closeOnClick`,l),l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},onClick(e){l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},id:h,[Za]:j?``:void 0,[bf]:j?void 0:``},f],stateAttributesMapping:qa})}),Cf=/*#__PURE__*/ y.createContext(void 0);function wf(){let e=y.useContext(Cf);if(e===void 0)throw Error(Pi(70));return e}let Tf=/*#__PURE__*/ y.forwardRef(function(e,t){let{children:n,container:r,className:i,render:a,style:o,...s}=e,{node:c,subtree:l}=ll({container:r,ref:t,componentProps:e,elementProps:s});return!l&&!c?null:/*#__PURE__*/ (0,A.jsxs)(y.Fragment,{children:[l,c&&/*#__PURE__*/ b.createPortal(n,c)]})}),Ef=/*#__PURE__*/ y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return Ii().useState(`mounted`)||n?/*#__PURE__*/ (0,A.jsx)(Cf.Provider,{value:n,children:/*#__PURE__*/ (0,A.jsx)(Tf,{ref:t,...r})}):null}),Df=/*#__PURE__*/ y.createContext(void 0);function Of(){let e=y.useContext(Df);if(e===void 0)throw Error(Pi(71));return e}function kf(e){let{nodeId:t,externalTree:n,rootContext:r}=e,i=r.useState(`referenceElement`),a=r.useState(`floatingElement`),o=r.useState(`domReferenceElement`),s=r.useState(`open`),c=r.useState(`floatingId`),[l,u]=y.useState(null),d=y.useRef(null),f=gl(n),p=y.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),m=af({...e,elements:{...p,...l&&{reference:l}}}),h=y.useCallback(e=>{let t=fa(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),m.refs.setReference(t)},[m.refs]),g=y.useMemo(()=>({...m.refs,setPositionReference:h,domReference:d}),[m.refs,h]),_=y.useMemo(()=>({...m.elements,domReference:o}),[m.elements,o]),v=y.useMemo(()=>({...m,dataRef:r.context.dataRef,open:s,onOpenChange:r.setOpen,events:r.context.events,floatingId:c,refs:g,elements:_,nodeId:t,rootStore:r}),[m,g,_,t,r,s,c]);return X(()=>{o&&(d.current=o)},[o]),X(()=>{r.context.dataRef.current.floatingContext=v;let e=f?.nodesRef.current.find(e=>e.id===t);e&&(e.context=v)}),y.useMemo(()=>({...m,context:v,refs:g,elements:_,rootStore:r}),[m,g,_,v,r])}let Af=/*#__PURE__*/ y.createContext(void 0);function jf(){return y.useContext(Af)?.direction??`ltr`}let Mf=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=ls(e,t)||{};if(l==null)return{};let d=Ds(u),f={x:n,y:r},p=hs(i),m=ps(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=s.floating[y]||a.floating[m],C=b/2-x/2,w=S/2-h[m]/2-1,T=Math.min(d[_],w),E=Math.min(d[v],w),D=T,O=S-h[m]-E,k=S/2-h[m]/2+C,A=cs(D,k,O),j=!c.arrow&&ds(i)!=null&&k!==A&&a.reference[m]/2-(k<D?T:E)-h[m]/2<0,M=j?k<D?k-D:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),Nf=(e,t)=>{let{name:n,fn:r}=Mf(e);return{name:n,fn:r,options:[e,t]}},Pf={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},Ff={sideX:`left`,sideY:`top`},If=`--available-width`,Lf=`--available-height`;function Rf(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function zf(e,t,n){let{rects:r,placement:i}=e;return{side:Rf(t,us(i),n),align:ds(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function Bf(e){return Vf(e,kf)}function Vf(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:b,adaptiveOrigin:x,lazyFlip:S=!1,externalTree:C}=e,w=_.side||`flip`,T=_.align||`flip`,E=_.fallbackAxisSide||`end`,D=v?.crossAxis??!1,O=v?.rootBoundary,k=typeof n==`function`?n:void 0,A=$(k),j=k?A:n,M=Vo(n),N=Vo(g),P=jf()===`rtl`,[F,I]=y.useState(null);!g&&F!==null&&I(null);let L=S===`placement`,R=F?us(F):null,z=F&&L?ds(F)||`center`:null,B=R||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":P?`left`:`right`,"inline-start":P?`right`:`left`}[i],V=z||o,H=V===`center`?B:`${B}-${V}`,U=l;typeof U==`number`?U={top:U,right:U,bottom:U,left:U}:U&&={top:U.top||0,right:U.right||0,bottom:U.bottom||0,left:U.left||0};let ee=+(i===`bottom`),te=+(i===`top`),ne=+(i===`right`),W=+(i===`left`),re={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:U},ie=y.useRef(null),G=Vo(a),K=Vo(s),q=typeof a==`function`?0:a,ae=typeof s==`function`?0:s,oe=[];p&&oe.push(p),oe.push(of(e=>{let t=zf(e,i,P),n=typeof G.current==`function`?G.current(t):G.current,r=typeof K.current==`function`?K.current(t):K.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[q,ae,P,i]));let se=T===`none`&&w!==`shift`,ce=!se&&(u||D||w===`shift`),le=w===`none`?null:lf({...re,padding:{top:U.top+1+ee,right:U.right+1+W,bottom:U.bottom+1+te,left:U.left+1+ne},mainAxis:!D&&w===`flip`,crossAxis:T===`flip`&&`alignment`,fallbackAxisSideDirection:E}),J=se?null:sf({...re,rootBoundary:O,mainAxis:T!==`none`,crossAxis:ce,limiter:u||D?void 0:cf(e=>{if(!ie.current)return{};let{width:t,height:n}=ie.current.getBoundingClientRect(),r=ms(us(e.placement)),i=r===`y`?t:n,a=r===`y`?U.left+U.right:U.top+U.bottom;return{offset:i/2+a/2}})},[re,u,D,O,U,T]);w===`shift`||T===`shift`||V===`center`?oe.push(J,le):oe.push(le,J),oe.push(uf({...re,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!N.current)return;let i=e.style;i.setProperty(If,`${t}px`),i.setProperty(Lf,`${n}px`);let a=la(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(`--anchor-width`,`${u}px`),i.setProperty(`--anchor-height`,`${d}px`)}}),Nf(e=>({element:ie.current||Zo(e.elements.floating).createElement(`div`),padding:ie.current?d:0}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=us(r),u=ds(r),d=ms(l)===`y`,f=ie.current,p=typeof a==`function`?a(zf(e,i,P)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return ce&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(`--transform-origin`,d?`${m} ${h}`:`${h} ${m}`),{}}},Pf,x),X(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let ue=y.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:de,elements:fe,x:pe,y:me,middlewareData:he,update:ge,placement:_e,context:ve,isPositioned:ye,floatingStyles:be}=t({rootContext:h,open:m?g:void 0,placement:H,middleware:oe,strategy:r,whileElementsMounted:m?void 0:(...e)=>Kd(...e,ue),nodeId:b,externalTree:C}),{sideX:xe,sideY:Se}=he.adaptiveOrigin||Ff,Ce=ye?r:`fixed`,we=y.useMemo(()=>{let e;return e=ye?x?{position:Ce,[xe]:pe,[Se]:me}:{...be,position:Ce}:{position:Ce,top:0,left:0},e[If]=`100vw`,e[Lf]=`100vh`,ye||(e.opacity=0),e},[x,Ce,xe,pe,Se,me,be,ye]),Te=y.useRef(null);X(()=>{if(!g)return;let e=M.current,t=typeof e==`function`?e():e,n=(Hf(t)?t.current:t)||null;n!==Te.current&&(de.setPositionReference(n),Te.current=n)},[g,de,j,M]),y.useEffect(()=>{if(!g)return;let e=M.current;typeof e!=`function`&&Hf(e)&&e.current!==Te.current&&(de.setPositionReference(e.current),Te.current=e.current)},[g,de,j,M]),y.useEffect(()=>{if(m&&g&&fe.reference&&fe.floating)return Kd(fe.reference,fe.floating,ge,ue)},[m,g,fe,ge,ue]);let Ee=us(_e),De=Rf(i,Ee,P),Oe=ds(_e)||`center`,ke=!!he.hide?.referenceHidden;X(()=>{S&&g&&ye&&(Ee!==B||L&&Oe!==V)&&I(_e)},[S,L,g,ye,_e,Ee,Oe,B,V]);let Ae=y.useMemo(()=>({position:`absolute`,top:he.arrow?.y,left:he.arrow?.x}),[he.arrow]),je=he.arrow?.centerOffset!==0;return y.useMemo(()=>({positionerStyles:we,arrowStyles:Ae,arrowRef:ie,arrowUncentered:je,side:De,align:Oe,physicalSide:Ee,anchorHidden:ke,refs:de,context:ve,isPositioned:ye,update:ge}),[we,Ae,ie,je,De,Oe,Ee,ke,de,ve,ye,ge])}function Hf(e){return e!=null&&`current`in e}function Uf(e){return e===`starting`?tl:Mi}function Wf(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),Jc(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},Uf(r),i],stateAttributesMapping:Ya})}let Gf=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`top`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=il,style:g,..._}=e,v=Ii(),b=wf(),x=v.useState(`open`),S=v.useState(`mounted`),C=v.useState(`trackCursorAxis`),w=v.useState(`disableHoverablePopup`),T=v.useState(`floatingRootContext`),E=v.useState(`instantType`),D=v.useState(`transitionStatus`),O=Bf({anchor:i,positionMethod:a,floatingRootContext:T,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,collisionBoundary:u,collisionPadding:d,sticky:p,arrowPadding:f,disableAnchorTracking:m,keepMounted:b,collisionAvoidance:h,adaptiveOrigin:v.useState(`adaptiveOrigin`)}),k=Wf(e,y.useMemo(()=>({open:x,side:O.side,align:O.align,anchorHidden:O.anchorHidden,instant:C===`none`?E:`tracking-cursor`}),[x,O.side,O.align,O.anchorHidden,C,E]),{styles:O.positionerStyles,transitionStatus:D,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!S,inert:!x||C===`both`||w});return/*#__PURE__*/ (0,A.jsx)(Df.Provider,{value:O,children:k})}),Kf=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Ii(),{side:s,align:c}=Of(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`disabled`),h=o.useState(`closeDelay`);Ql({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),Ku(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return Jc(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[eu,f,Uf(d),a],stateAttributesMapping:Xa})}),qf=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Ii(),{arrowRef:s,side:c,align:l,arrowUncentered:u,arrowStyles:d}=Of();return Jc(`div`,e,{state:{open:o.useState(`open`),side:c,align:l,uncentered:u,instant:o.useState(`instantType`)},ref:[t,s],props:[{style:d,"aria-hidden":!0},a],stateAttributesMapping:Ya})});function Jf(e){return Oc(19)?e:e?`true`:void 0}function Yf(e){let[t,n]=y.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}let Xf=/* @__PURE__ */ new Set;function Zf({label:e,side:t=`top`,describe:n=!0,wrap:r=!1,disabled:i=!1,children:a}){let o=y.useId(),[s,c]=y.useState(!1),l=y.useCallback(()=>c(!1),[]),u=s&&!i;return y.useEffect(()=>{if(!u)return;let e=e=>{let t=e.target;t instanceof Element&&t.closest(`[data-ui-tip="${o}"]`)||l()};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`scroll`,l,!0),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`scroll`,l,!0)}},[u,l,o]),y.useEffect(()=>{if(u){for(let e of Xf)e!==l&&e();return Xf.add(l),()=>{Xf.delete(l)}}},[u,l]),/* @__PURE__ */ (0,A.jsxs)(hf,{disabled:i,open:u,onOpenChange:c,children:[/* @__PURE__ */ (0,A.jsx)(Sf,{delay:0,render:a,"aria-describedby":n&&!i?o:void 0,onBlur:l,"data-ui-tip":o}),n&&!i?/* @__PURE__ */ (0,A.jsx)(`span`,{id:o,hidden:!0,children:e}):null,/* @__PURE__ */ (0,A.jsx)(Ef,{children:/* @__PURE__ */ (0,A.jsx)(Gf,{side:t,sideOffset:8,className:`ui-tooltip-positioner`,children:/* @__PURE__ */ (0,A.jsxs)(Kf,{className:r?`ui-tooltip is-wrap`:`ui-tooltip`,children:[e,/* @__PURE__ */ (0,A.jsx)(qf,{className:`ui-tooltip-arrow`})]})})})]})}Fe(),Pr(),Mn(),ti(Pe,Nr,jn);let Qf=e=>!!e&&typeof e==`object`&&!y.isValidElement(e)&&!Array.isArray(e)&&typeof e.name==`string`;function $f({brand:e,collapsed:t}){let n=Qf(e)?e:typeof e==`string`?{name:e}:null;if(G(!n&&t,`SideNav`,`brand 是一個元素,收合時讀不出哪部分是 logo,只能整塊藏起來。改傳 brand={{ mark, name, href }}:收合時顯示 mark,展開時加上名稱。`),!n)return/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-nav-brand`,children:t?null:e});let r=/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-nav-mark`,"aria-hidden":`true`,children:n.mark??/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-nav-monogram`,children:Array.from(n.name)[0]})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-nav-brand-name`,children:n.name})]}),i=t?n.name:void 0;return/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-nav-brand has-mark`,children:n.href?/* @__PURE__ */ (0,A.jsx)(`a`,{className:`ui-nav-brand-link`,href:n.href,onClick:n.onClick,"aria-label":i,children:r}):n.onClick?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-nav-brand-link`,onClick:n.onClick,"aria-label":i,children:r}):/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-nav-brand-link`,"aria-label":i,role:i?`img`:void 0,children:r})})}function ep({sections:e,value:t,onChange:n,collapsed:r=!1,onToggle:i,onPin:a,pinned:o=!1,brand:s,label:c,className:l}){let u=y.useRef({}),d=y.useRef(null),[f,p]=y.useState({top:0,bottom:0,show:!1,down:!0}),m=y.useRef(null),[h,g]=gi(),_=y.useRef(t);y.useEffect(()=>{if(t===_.current)return;_.current=void 0;let n=e.flatMap(e=>e.items.flatMap(e=>[e,...e.children??[]])).find(e=>e.id===t);n&&bi(n.label)},[t]);let[v,b]=y.useState({}),x=Object.keys(v).filter(e=>v[e]).join();y.useLayoutEffect(()=>{let n=u.current[t];if(!n){let r=e.flatMap(e=>e.items).find(e=>e.children?.some(e=>e.id===t));n=r?u.current[r.id]:null}let r=d.current;if(!n||!r)return;let i=n.getBoundingClientRect().top-r.getBoundingClientRect().top,a=Math.round(i)+8,o=Math.round(r.clientHeight-i-n.offsetHeight)+8,s=m.current;s&&s.top===a&&s.bottom===o||(s&&s.top!==a&&g(),m.current={top:a,bottom:o},p({top:a,bottom:o,show:!0,down:!s||a>=s.top}))},[t,r,x,e,g]);let S=(e,i)=>{let a=e.children??[],o=a.length>0&&!r,s=!v[e.id],c=t===e.id||(!o||!s)&&a.some(e=>e.id===t),l=[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-nav-row`,children:[/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,ref:t=>{u.current[e.id]=t},className:M(`ui-nav-item`,i&&`is-sub`,c&&`is-selected`),"aria-current":c?`page`:void 0,"aria-expanded":o?s:void 0,"aria-label":r?e.label:void 0,onClick:()=>o?b({...v,[e.id]:s}):n?.(a[0]?.id??e.id),children:[e.icon&&!i?/* @__PURE__ */ (0,A.jsx)(fi,{icon:e.icon,size:22,filled:c,className:`ui-nav-icon`}):null,r?null:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-nav-label`,children:e.label}),o?/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-right`,size:16,className:M(`ui-nav-chev`,s&&`is-open`)}):null]}),r?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-nav-tip`,role:`tooltip`,children:e.label}):null]},e.id)];if(o&&s)for(let e of a)l.push(...S(e,!0));return l},C=w(r?`展開側邊欄`:`收合側邊欄`);return/* @__PURE__ */ (0,A.jsxs)(`aside`,{className:M(`ui-sidenav`,r&&`is-collapsed`,l),children:[s?/* @__PURE__ */ (0,A.jsx)($f,{brand:s,collapsed:r}):null,/* @__PURE__ */ (0,A.jsx)(`nav`,{className:`ui-nav-list`,"aria-label":c||w(`主要導覽`),children:/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:d,className:`ui-nav-inner`,children:[f.show?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-nav-bar`,"aria-hidden":`true`,style:{top:f.top,bottom:f.bottom,transform:h?`scaleX(.7)`:`none`,transition:hi(`top`,`bottom`,f.down)}}):null,e.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(y.Fragment,{children:[t>0?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-nav-divider`,role:`separator`}):null,e.items.flatMap(e=>S(e,!1))]},t))]})}),i||a?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-nav-foot`,children:[a?/* @__PURE__ */ (0,A.jsx)(Zf,{label:w(o?`取消釘選`:`釘選側邊欄`),side:`right`,describe:!1,children:/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:M(`ui-nav-collapse`,`ui-nav-pin`,o&&`is-on`),"aria-pressed":o,"aria-label":w(o?`取消釘選`:`釘選側邊欄`),onClick:a,children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`push-pin`,size:20,filled:o})})}):null,i?/* @__PURE__ */ (0,A.jsx)(Zf,{label:C,side:`right`,describe:!1,children:/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-nav-collapse`,"aria-label":C,onClick:i,children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`sidebar-simple`,size:20})})}):null]}):null]})}function tp({items:e,className:t}){return/* @__PURE__ */ (0,A.jsx)(`nav`,{className:M(`ui-crumb`,t),"aria-label":w(`路徑`),children:/* @__PURE__ */ (0,A.jsx)(`ol`,{children:e.map((t,n)=>{let r=n===e.length-1;return/* @__PURE__ */ (0,A.jsxs)(`li`,{children:[r?/* @__PURE__ */ (0,A.jsx)(`span`,{"aria-current":`page`,children:t.label}):t.href?/* @__PURE__ */ (0,A.jsx)(`a`,{href:t.href,children:t.label}):/* @__PURE__ */ (0,A.jsx)(`span`,{children:t.label}),r?null:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-crumb-sep`,"aria-hidden":`true`,children:`›`})]},n)})})})}ir(),ti(rr);function np({label:e,icon:t,className:n,tooltip:r=!0,filled:i,hint:a,variant:o,...s}){let c=y.useId(),l=/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,...s,className:M(`ui-iconbtn`,o===`quiet`&&`is-quiet`,a&&`has-hint`,n),"aria-label":e,"aria-describedby":a?c:s[`aria-describedby`],children:[/* @__PURE__ */ (0,A.jsx)(fi,{icon:t,filled:i}),a&&/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-iconbtn-dot`,"aria-hidden":`true`})]}),u=r?/* @__PURE__ */ (0,A.jsx)(Zf,{label:e,describe:!1,children:l}):l;return a?/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-iconbtn-hintbox`,children:[u,/* @__PURE__ */ (0,A.jsx)(rp,{id:c,hint:a})]}):u}function rp({id:e,hint:t}){let n=y.useRef(null),[r,i]=y.useState(null);y.useLayoutEffect(()=>{let e=n.current;if(!e)return;let t=()=>{let t=e.parentElement?.getBoundingClientRect();if(!t)return;let n=Math.floor(t.left-12-8);if(n>=180)return i({room:n});let r=Math.min(320,window.innerWidth-32),a=t.left+t.width-r,o=Math.max(16,Math.min(a,window.innerWidth-16-r));i({room:n,left:Math.round(o-t.left),arrow:Math.round(t.left+t.width/2-o-6)})};return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[]);let a=r!=null&&r.room<180;return/* @__PURE__ */ (0,A.jsxs)(`span`,{ref:n,className:M(`ui-hint`,a&&`is-below`),id:e,role:`status`,style:r==null?void 0:a?{left:r.left,right:`auto`,"--hint-arrow":r.arrow+`px`}:{maxWidth:Math.min(320,r.room)},children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-hint-text`,children:t.text}),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-hint-go`,onClick:t.onAction,children:t.action??w(`開始`)}),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-hint-x`,"aria-label":w(`關閉提示`),onClick:t.onDismiss,children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`,size:16})})]})}rn(),cn(),ti(nn,sn);function ip({title:e,breadcrumb:t,onSearch:n,searchLabel:r,children:i,onMenu:a,className:o}){let s=H(B);return/* @__PURE__ */ (0,A.jsxs)(`header`,{className:M(`ui-topbar`,o),children:[a?/* @__PURE__ */ (0,A.jsx)(np,{className:`ui-topbar-menu`,icon:`list-bullets`,label:w(`開啟導覽`),onClick:a}):null,e?/* @__PURE__ */ (0,A.jsx)(`h1`,{className:`ui-topbar-title`,children:e}):null,t?/* @__PURE__ */ (0,A.jsx)(tp,{items:t}):null,/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-topbar-end`,children:[n===!1?null:/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:`ui-search`,"data-tour":`search`,onClick:n,"aria-keyshortcuts":z?`Meta+K`:`Control+K`,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`magnifying-glass`,size:16}),/* @__PURE__ */ (0,A.jsx)(`span`,{children:r||w(`搜尋`)}),s?null:/* @__PURE__ */ (0,A.jsx)(`kbd`,{children:V})]}),/* @__PURE__ */ (0,A.jsx)(np,{className:`ui-search-icon`,"data-tour":`search`,icon:`magnifying-glass`,label:s?w(`搜尋`):w(`搜尋({k})`,{k:V}),onClick:n})]}),i]})]})}function ap({items:e,value:t,onChange:n,label:r,labels:i=!0,className:a}){let o=Math.max(0,e.findIndex(e=>e.id===t)),[s,c]=y.useState(!0),l=100/Math.max(1,e.length);return/* @__PURE__ */ (0,A.jsxs)(`nav`,{className:M(`ui-tabbar`,i&&`has-labels`,a),"aria-label":r||w(`主要導覽`),children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tabbar-pill`,"aria-hidden":`true`,style:{left:`calc(${o*l+l/2}% - 28px)`,right:`calc(${100-o*l-l/2}% - 28px)`,transition:hi(`left`,`right`,s)}}),e.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-tabbar-item`,t===o&&`is-selected`),"aria-label":i?void 0:e.label,"aria-current":t===o?`page`:void 0,onClick:()=>{t!==o&&c(t>o),n?.(e.id)},children:[/* @__PURE__ */ (0,A.jsx)(fi,{icon:e.icon,size:22,filled:t===o}),i?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tabbar-label`,children:e.label}):null]},e.id))]})}let op=/*#__PURE__*/ y.createContext(void 0);function sp(e){let t=y.useContext(op);if(!e&&t===void 0)throw Error(Pi(27));return t}let cp=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=sp(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return Jc(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:Xa,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),lp=/*#__PURE__*/ y.createContext(void 0);function up(e=!1){let t=y.useContext(lp);if(t===void 0&&!e)throw Error(Pi(16));return t}function dp(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:y.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function fp(e,t,{detail:n=0,pointerType:r=``}={}){e.dispatchEvent(new(la(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,pointerType:r,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function pp(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=y.useRef(null),s=up(!0),c=a??s!==void 0,{props:l}=dp({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=y.useCallback(()=>{let e=o.current;mp(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return X(u,[u]),{getButtonProps:y.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return Fc({onClick(e){t?e.preventDefault():n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(Gc(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=mp(r),s=!i&&hp(r),l=n&&(i?a:!s),u=e.key===`Enter`,d=e.key===` `,f=r.getAttribute(`role`),p=f?.startsWith(`menuitem`)||f===`option`||f===`gridcell`;if(n&&c&&d){if(e.defaultPrevented&&p)return;e.preventDefault(),(!i||a)&&(e.preventBaseUIHandler(),fp(r,e))}else!l||i||!d&&!u?n&&s&&d&&e.preventDefault():e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),fp(r,e)))},onKeyUp(e){t||(Gc(e),a?.(e),e.target===e.currentTarget&&i&&c&&mp(e.currentTarget)&&e.key===` `?e.preventDefault():e.baseUIHandlerPrevented||e.target!==e.currentTarget||i||c||e.defaultPrevented||e.key!==` `||(e.preventBaseUIHandler(),fp(e.currentTarget,e)))},onPointerDown(e){t?e.preventDefault():s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:$(e=>{o.current=e,u()})}}function mp(e){return pa(e)&&e.tagName===`BUTTON`}function hp(e){return pa(e)&&e.tagName===`A`&&!!e.href}let gp=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=sp(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=pp({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,Q(vo,e.nativeEvent))}return Jc(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})}),_p=/*#__PURE__*/ y.createContext(void 0);function vp(){let e=y.useContext(_p);if(e===void 0)throw Error(Pi(26));return e}let yp=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),bp={...Ya,...Ba,nestedDialogOpen(e){return e?{"data-nested-dialog-open":``}:null}},xp=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=sp(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);vp(),Ql({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?tu(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=Jc(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...eu,hidden:!m,onKeyDown(e){yp.has(e.key)&&e.stopPropagation()},style:{"--nested-dialogs":g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:bp});return/*#__PURE__*/ (0,A.jsx)(Ol,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})}),Sp=/*#__PURE__*/ y.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return/*#__PURE__*/ (0,A.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})}),Cp=/*#__PURE__*/ y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=sp(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?/*#__PURE__*/ (0,A.jsx)(_p.Provider,{value:n,children:/*#__PURE__*/ (0,A.jsxs)(ul,{ref:t,...r,children:[a&&o===!0&&/*#__PURE__*/ (0,A.jsx)(Sp,{ref:i.context.internalBackdropRef,inert:Jf(!s)}),e.children]})}):null}),wp={},Tp={},Ep=``;function Dp(e,t){return ha(e)?e:t}function Op(e,t,n){return/hidden|clip/.test(e.getComputedStyle(Dp(t,n)).overflowY)}function kp(e){if(typeof document>`u`)return!1;let t=Zo(e);return la(t).innerWidth-t.documentElement.clientWidth>0}function Ap(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=Zo(e),n=t.documentElement,r=t.body,i=Dp(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function jp(e){let t=Zo(e),n=t.documentElement,r=t.body,i=Dp(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function Mp(e){let t=Zo(e),n=t.documentElement,r=t.body,i=la(n),a=0,o=0,s=!1,c=Yo.create();if(Zi&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,wp={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},Ep=n.style.scrollBehavior,Tp={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=Dp(n,r);s=Ap(e),s?(n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`):(Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`)}function u(){Object.assign(n.style,wp),Object.assign(r.style,Tp),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=Ep)}function d(){u(),c.request(l)}l();let f=No(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}let Np=new class{lockCount=0;restore=null;timeoutLock=Ri.create();timeoutUnlock=Ri.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=Zo(e),n=t.documentElement,r=t.body,i=la(n);if(Op(i,n,r)){let t=new i.MutationObserver(()=>{Op(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=Ki||!kp(e);this.restore=a?jp(e):Mp(e)}};function Pp(e=!0,t=null){X(()=>{if(e)return Np.acquire(t)},[e,t])}function Fp({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`mounted`),a=e.useState(`disablePointerDismissal`),o=e.useState(`modal`),s=e.useState(`popupElement`),c=e.useState(`floatingRootContext`),[l,u]=y.useState(0),[d,f]=y.useState(0),p=l===0,m=Fl(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:o===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=Pa(t);if(p&&!a){if(o){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||Z(n,s)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:p});return Pp(r&&o===!0,s),e.useContextCallback(`onNestedDialogOpen`,(t,n)=>{(e.select(`open`)||e.select(`mounted`))&&(u(t),f(n))}),X(()=>{!r&&!i&&(u(0),f(0))},[r,i]),X(()=>(t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(l+1,d+ +!!n),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,l,d,t]),fu(e,{activeTriggerProps:m.reference,inactiveTriggerProps:m.trigger,popupProps:m.floating,nestedOpenDialogCount:l,nestedOpenDrawerCount:d}),null}let Ip={...Iu,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role};var Lp=class extends Du{constructor(e,t,n){let r=new mu,i=Rp(e,r,t,n);super(i,zp(r),Ip)}setOpen=(e,t)=>{t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled||(this.state.floatingRootContext.dispatchOpenChange(e,t),this.update(ou(this.state,e,t.trigger)))}};function Rp(e,t,n,r=!1){return{...Au(t,n,r),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}function zp(e){return{popupRef:/*#__PURE__*/ y.createRef(),backdropRef:/*#__PURE__*/ y.createRef(),internalBackdropRef:/*#__PURE__*/ y.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function Bp(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:d,defaultTriggerId:f=null}=t,p=e===`drawer`,m=e===`alert-dialog`,h=m?!0:c,g=m||s,_=m?`alertdialog`:`dialog`,v=sp(!0),b={modal:h,disablePointerDismissal:g,nested:v!=null,role:_},x=nu((e,t)=>new Lp({open:i,openProp:r,activeTriggerId:f,triggerIdProp:d,...b},e,t),!0);x.useControlledProp(`openProp`,r),x.useControlledProp(`triggerIdProp`,d),x.useSyncedValues(b),x.useContextCallback(`onOpenChange`,a),x.useContextCallback(`onOpenChangeComplete`,o);let S=x.useState(`open`),C=x.useState(`mounted`),w=x.useState(`payload`);pu(x,S),uu(x);let{forceUnmount:T}=du(S,x);y.useImperativeHandle(l,()=>({unmount:T,close:()=>x.setOpen(!1,Q(ko))}),[T,x]);let E=S||C||u!=null;return/*#__PURE__*/ (0,A.jsxs)(op.Provider,{value:x,children:[u&&/*#__PURE__*/ (0,A.jsx)(ru,{handle:u,store:x}),E&&/*#__PURE__*/ (0,A.jsx)(Fp,{store:x,parentContext:v?.context,isDrawer:p}),typeof n==`function`?n({payload:w}):n]})}let Vp=Di(function(e){return Bp(`dialog`,e)}),Hp=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=vp(),c=sp(),l=c.useState(`open`),u=c.useState(`nested`),d=c.useState(`transitionStatus`),f=c.useState(`nestedOpenDialogCount`),p=c.useState(`mounted`),m=c.useStateSetter(`viewportElement`);return Jc(`div`,e,{enabled:s||p,state:{open:l,nested:u,transitionStatus:d,nestedDialogOpen:f>0},ref:[t,m],stateAttributesMapping:bp,props:[{role:`presentation`,hidden:!p,style:{pointerEvents:l?void 0:`none`},children:a},o]})}),Up=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=sp(),c=_f(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),Jc(`h2`,e,{ref:t,props:[{id:c},o]})});function Wp(e){let t=y.useRef(``),n=y.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:y.useCallback(n=>{n.detail===0?e(n,`keyboard`):(`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``)},[e]),onPointerDown:n}}function Gp(e,t){let n=y.useRef(e),r=$(t);X(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function Kp(e,t){let{onClick:n,onPointerDown:r}=Wp($((n,r)=>{(typeof e==`function`?e():e)||t(r||(Ki?`touch`:``))}));return y.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function qp(e){let[t,n]=y.useState(null),r=Kp(e,n);return Gp(e,t=>{t&&!e&&n(null)}),y.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}let Jp=Oi(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,payload:c,handle:l,...u}=e,d=sp(!0),f=Lu(l)??d;if(!f)throw Error(Pi(79));let p=_f(s),m=f.useState(`floatingRootContext`),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`triggerPopupId`,p),_=y.useRef(null),{registerTrigger:v,isMountedByThisTrigger:b}=lu(p,_,f,{payload:c}),{getButtonProps:x,buttonRef:S}=pp({disabled:a,native:o}),C=kl(m),w=Kp(()=>f.select(`open`),e=>{f.set(`openMethod`,e)}),T={disabled:a,open:h},E=f.useState(`triggerProps`,b);return Jc(`button`,e,{state:T,ref:[S,t,v,_],props:[C.reference,E,w,{[nl]:``,id:p,"aria-haspopup":`dialog`,"aria-expanded":h,"aria-controls":g},u,x],stateAttributesMapping:qa})});Ze(),ti(Xe);function Yp(){return/* @__PURE__ */ (0,A.jsx)(Y,{name:`circle-notch`,className:`ui-spin`,size:16})}function Xp(e){let{variant:t=`secondary`,loading:n,icon:r,className:i,children:a,disabled:o,onClick:s,...c}=e,{confirm:l,confirmed:u,...d}=c,[f,p]=y.useState(!1);G(t===`danger`&&!l&&!u,`Button`,`a danger button needs confirm={{ title }} (or confirmed when it is the button inside the confirm Dialog).`);let m=y.useRef(null),h=/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,...d,className:M(`ui-btn`,`ui-btn-`+t,n&&`is-loading`,i),disabled:o||n,"aria-busy":n||void 0,onClick:e=>{l?(e.preventDefault(),m.current={event:e,button:e.currentTarget},p(!0)):s?.(e)},children:[n?/* @__PURE__ */ (0,A.jsx)(Yp,{}):r?/* @__PURE__ */ (0,A.jsx)(fi,{icon:r}):null,a]});return l?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[h,/* @__PURE__ */ (0,A.jsx)(am,{open:f,onClose:()=>p(!1),title:l.title,tone:`danger`,confirmLabel:l.confirmLabel??(typeof a==`string`?a:w(`刪除`)),onConfirm:()=>{p(!1);let e=m.current;e&&(s?.(e.event),e.button.type===`submit`&&e.button.form?.requestSubmit(e.button))},children:l.body})]}):h}let Zp=/(`[^`]+`)/;function Qp(e){return String(e??``).split(Zp).map((e,t)=>t%2?{code:!0,text:e.slice(1,-1)}:{code:!1,text:e}).filter(e=>e.text!==``)}let $p=e=>!!e&&Zp.test(e);function em({children:e,href:t,onClick:n,className:r,look:i=`chip`}){let[a,o]=y.useState(!1),s=y.useCallback(e=>{let t=e?.parentNode;o(!!t&&Array.from(t.childNodes).some(e=>e.nodeType===3&&!!e.textContent?.trim()))},[]),c=!!(t||n),l=M(`ui-code`,c&&`is-link`,c&&a&&`is-inline`,c&&i!==`chip`&&`is-${i}`,typeof e==`string`&&e.length<=24&&`is-short`,r);return t?/* @__PURE__ */ (0,A.jsx)(`a`,{ref:s,className:l,href:t,onClick:n,children:e}):n?/* @__PURE__ */ (0,A.jsx)(`button`,{ref:s,type:`button`,className:l,onClick:n,children:e}):/* @__PURE__ */ (0,A.jsx)(`code`,{className:l,children:e})}let tm=/^[\w./-]+\.[A-Za-z0-9]+:\d+(-\d+)?$/,nm=e=>tm.test(e);function rm({text:e,refHref:t,onRef:n,isRef:r=nm,as:i=`span`,className:a}){return/* @__PURE__ */ (0,A.jsx)(i,{className:a,children:Qp(e).map(({code:e,text:i},a)=>{if(!e)return i;let o=t&&r(i)&&t(i)||void 0;if(!(r(i)&&(t?o:n)))return/* @__PURE__ */ (0,A.jsx)(em,{children:i},a);let s=n?e=>{o&&(e.metaKey||e.ctrlKey||e.shiftKey||e.button===1)||(e.preventDefault(),n(i,e))}:void 0;return o?/* @__PURE__ */ (0,A.jsx)(em,{look:`location`,href:o,onClick:s,children:i},a):s?/* @__PURE__ */ (0,A.jsx)(em,{look:`location`,onClick:s,children:i},a):/* @__PURE__ */ (0,A.jsx)(em,{children:i},a)})})}function im(e){return typeof e!=`string`||!$p(e)?e:Qp(e).map((e,t)=>e.code?/* @__PURE__ */ (0,A.jsx)(em,{children:e.text},t):e.text)}ir(),ti(rr);function am(e){let{open:t,onClose:n,title:r,children:i,confirmLabel:a,onConfirm:o,cancelLabel:s,tone:c=`default`,confirmLoading:l,actions:u,className:d}=e;G(a!==void 0!=!!o,`Dialog`,`confirmLabel and onConfirm go together; pass both, or pass actions.`),G(t===void 0&&e.modal!==!1,`Dialog`,`pass open={…} (and onClose) to show a dialog; rendering it conditionally without open draws a static panel with no focus trap or Esc. Use modal={false} for a static preview.`),G(t!==void 0&&!n,`Dialog`,`an open dialog needs onClose, or Esc and the backdrop cannot close it.`);let f=u??(a&&o?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(Xp,{onClick:n,children:s??w(`取消`)}),c===`danger`?/* @__PURE__ */ (0,A.jsx)(Xp,{variant:`danger`,confirmed:!0,loading:l,onClick:o,children:a}):/* @__PURE__ */ (0,A.jsx)(Xp,{variant:`primary`,loading:l,onClick:o,children:a})]}):null),p=y.useId(),m=t===void 0,h=/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`}),g=/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dialog-head`,children:[m?/* @__PURE__ */ (0,A.jsx)(`div`,{id:p,className:`ui-dialog-title`,children:r}):/* @__PURE__ */ (0,A.jsx)(Up,{className:`ui-dialog-title`,children:r}),n&&m?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-dialog-close`,"aria-label":w(`關閉`),onClick:n,children:h}):n?/* @__PURE__ */ (0,A.jsx)(gp,{className:`ui-dialog-close`,"aria-label":w(`關閉`),children:h}):null]}),_=/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[g,i?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dialog-body`,children:im(i)}):null,f?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dialog-actions`,children:f}):null]});return m?/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-dialog`,d),role:`dialog`,"aria-labelledby":p,children:_}):/* @__PURE__ */ (0,A.jsx)(Vp,{open:t,onOpenChange:e=>!e&&n?.(),children:/* @__PURE__ */ (0,A.jsxs)(Cp,{children:[/* @__PURE__ */ (0,A.jsx)(cp,{className:`ui-backdrop`}),/* @__PURE__ */ (0,A.jsx)(Hp,{className:`ui-dialog-viewport`,children:/* @__PURE__ */ (0,A.jsx)(xp,{className:M(`ui-dialog`,d),children:_})})]})})}ir(),ti(rr);function om({open:e,onClose:t,title:n,actions:r,dirty:i,width:a,side:o=`right`,confirmTitle:s,confirmText:c,children:l}){let[u,d]=y.useState(!1),f=()=>i?d(!0):t(),p=y.useRef(null);return/* @__PURE__ */ (0,A.jsx)(Vp,{open:e,onOpenChange:e=>!e&&f(),children:/* @__PURE__ */ (0,A.jsxs)(Cp,{children:[/* @__PURE__ */ (0,A.jsx)(cp,{className:`ui-drawer-backdrop`}),/* @__PURE__ */ (0,A.jsxs)(xp,{ref:p,initialFocus:()=>p.current?.querySelector(`.ui-drawer-body :is(input, textarea, select, button, [tabindex]):not([disabled], [tabindex="-1"]), .ui-drawer-foot button:not([disabled])`)??!0,className:o===`left`?`ui-drawer is-left`:`ui-drawer`,style:a?{width:a}:void 0,children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-drawer-head`,children:[/* @__PURE__ */ (0,A.jsx)(Up,{className:`ui-drawer-title`,children:n}),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-drawer-close ui-dialog-close`,"aria-label":w(`關閉`),onClick:f,children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`})})]}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-drawer-body`,children:l}),r?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-drawer-foot`,children:typeof r==`function`?r(f):r}):null,/* @__PURE__ */ (0,A.jsx)(am,{open:u,onClose:()=>d(!1),title:s||w(`放棄未儲存的變更?`),tone:`danger`,cancelLabel:w(`繼續編輯`),confirmLabel:w(`放棄`),onConfirm:()=>{d(!1),t()},children:im(c||w(`關閉後,剛才的修改不會保留。`))})]})]})})}let sm=`pointer`;typeof document<`u`&&(document.addEventListener(`keydown`,()=>sm=`key`,!0),document.addEventListener(`pointerdown`,()=>sm=`pointer`,!0));function cm(){if(typeof document>`u`)return;let e=document.querySelector(`main`),t=e?.querySelector(`h1, h2`)??document.querySelector(`.ui-topbar-title`)??e;t&&(t.tabIndex<0&&!t.hasAttribute(`tabindex`)&&t.setAttribute(`tabindex`,`-1`),t.setAttribute(`data-ui-main-focus`,sm),t.focus({preventScroll:!1}))}lt(),ti(ct);let lm=`ui-nav-collapsed`,um=`ui-nav-pinned`,dm=`\0more`;function fm({nav:e,value:t,onNavigate:n,brand:r,title:i,breadcrumb:a,onSearch:o,actions:s,children:c,tabLabels:l,defaultPinned:u=!1,className:d}){let f=ee(),p=H(`(min-width: 600px) and (max-width: 1024px)`),[m,h]=y.useState(()=>I(lm)===`1`),[g,_]=y.useState(()=>{let e=I(um);return e==null?I(lm)!=null||u:e===`1`}),[v,b]=y.useState(!1),x=y.useRef(void 0),S=y.useRef(void 0),C=e=>{clearTimeout(x.current),clearTimeout(S.current),e?x.current=setTimeout(()=>b(!0),100):S.current=setTimeout(()=>b(!1),300)};y.useEffect(()=>()=>{clearTimeout(x.current),clearTimeout(S.current)},[]);let T=g?m:!v,E=()=>{I(um,g?`0`:`1`),_(!g),b(!1)},D=e.flatMap(e=>e.items),O=e=>D.find(t=>t.children?.some(t=>t.id===e)),k=D.filter(e=>!!e.icon),j=D.some(e=>!e.icon||(e.children?.length??0)>1)||k.length>5,N=k.slice(0,j?4:5).map(e=>({id:e.id,label:e.label,icon:e.icon}));j&&N.push({id:dm,label:w(`更多`),icon:`dots-three`});let[P,F]=y.useState(!1);P&&!f&&!p&&F(!1),G(f&&k.length<2,`AppShell`,`phones show the top-level nav items as bottom tabs; give at least 2 of them an icon.`);let L=O(t)?.id??t,R=N.some(e=>e.id===L)?L:dm,z=e=>{if(e===dm)return F(!0);e!==L&&n(D.find(t=>t.id===e)?.children?.[0]?.id??e)},B=y.useRef(null),[V,U]=y.useState(!1);return y.useEffect(()=>{let e=B.current;if(!e)return;let t=e.scrollTop,n=()=>{let n=e.scrollTop;Math.abs(n-t)<8||(U(n>t&&n>64),t=n)};return e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},[]),y.useEffect(()=>{yi()},[]),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-shell`,f&&`is-phone`,d),children:[/* @__PURE__ */ (0,A.jsx)(`a`,{className:`ui-skip`,href:`#main`,onClick:e=>{e.preventDefault(),cm()},children:w(`跳到主要內容`)}),f||p?null:g?/* @__PURE__ */ (0,A.jsx)(ep,{sections:e,value:t,onChange:n,brand:r,collapsed:T,pinned:!0,onPin:E,onToggle:()=>{I(lm,m?`0`:`1`),h(!m)}}):/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-shell-rail`,v&&`is-open`),onPointerEnter:e=>e.pointerType===`mouse`&&C(!0),onPointerLeave:e=>e.pointerType===`mouse`&&C(!1),onFocus:e=>{e.target.matches(`:focus-visible`)&&(clearTimeout(S.current),b(!0))},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||b(!1)},onKeyDown:e=>{e.key===`Escape`&&v&&(e.stopPropagation(),b(!1))},children:/* @__PURE__ */ (0,A.jsx)(ep,{sections:e,value:t,onChange:e=>{clearTimeout(x.current),b(!1),n(e)},brand:r,collapsed:T,onPin:E})}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-shell-body`,children:[/* @__PURE__ */ (0,A.jsx)(ip,{className:M(`ui-shell-top`,V&&`is-hidden`),title:i,breadcrumb:a,onSearch:o??!1,onMenu:p?()=>F(!0):void 0,children:s}),/* @__PURE__ */ (0,A.jsx)(`main`,{ref:B,className:`ui-shell-main`,tabIndex:-1,children:c}),f&&N.length?/* @__PURE__ */ (0,A.jsx)(ap,{items:N,value:R,onChange:z,labels:l}):null,f||p?/* @__PURE__ */ (0,A.jsx)(om,{open:P,onClose:()=>F(!1),title:w(`全部頁面`),side:p?`left`:`right`,width:p?300:void 0,children:/* @__PURE__ */ (0,A.jsx)(ep,{className:`ui-shell-allnav`,sections:e,value:t,onChange:e=>{F(!1),n(e)}})}):null]})]})}function pm({columns:e=3,children:t,className:n}){return/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-grid`,`is-`+e,n),children:t})}function mm({children:e,className:t}){return/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-page`,t),children:e})}let hm=`ui-theme`,gm=`ui-accent`,_m=e=>e===`auto`||e===`light`||e===`dark`;function vm(){let e=I(hm);return _m(e)?e:`auto`}function ym(e){return e===`auto`?typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:e}let bm;function xm(e){let t=document.documentElement;L()||(t.classList.add(`ui-theme-fade`),clearTimeout(bm),bm=setTimeout(()=>t.classList.remove(`ui-theme-fade`),320)),t.setAttribute(`data-theme`,ym(e)),t.setAttribute(`data-theme-setting`,e),I(hm,e),Pm(Cm(),!0)}let Sm={"#8a4fd6":`#864ad1`,"#c2407a":`#ba3873`,"#cd3a2f":`#c53228`,"#b85a0e":`#ab5101`,"#1a844a":`#077b42`,"#0e827d":`#027874`};function Cm(){let e=I(gm);if(!e)return`#2457d6`;let t=Sm[e.toLowerCase()];return t&&I(gm,t),t??e}let wm=e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16));function Tm(e){let t=e.trim().toLowerCase(),n=/^#([0-9a-f])([0-9a-f])([0-9a-f])[0-9a-f]?$/.exec(t);if(n)return`#`+n[1]+n[1]+n[2]+n[2]+n[3]+n[3];let r=/^#([0-9a-f]{6})(?:[0-9a-f]{2})?$/.exec(t);if(r)return`#`+r[1];let i=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*[\d.]+%?)?\s*\)$/.exec(t);if(i){let e=i.slice(1,4).map(Number);if(e.every(e=>e>=0&&e<=255))return`#`+e.map(e=>Math.round(e).toString(16).padStart(2,`0`)).join(``)}return null}function Em(e,t,n){let r=wm(e),i=wm(t);return`#`+r.map((e,t)=>Math.round(e+(i[t]-e)*n).toString(16).padStart(2,`0`)).join(``)}function Dm(e){let t=[.2126,.7152,.0722];return wm(e).map(e=>(e/=255,e<=.03928?e/12.92:((e+.055)/1.055)**2.4)).reduce((e,n,r)=>e+n*t[r],0)}function Om(e,t){let n=Dm(e),r=Dm(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function km(e,t,n,r,...i){let a=[n,r,...i].map(Tm);if(a.some(e=>!e))return e;let o=e=>a.every(t=>Om(e,t)>=4.5),s=t?`#ffffff`:`#000000`,c=t?.05:.04,l=e;for(let t=1;t*c<=1&&!o(l);t++)l=Em(e,s,t*c);return l}let Am=`#171512`;function jm(e){return Om(`#ffffff`,e)>=Om(Am,e)?`#ffffff`:Am}function Mm(e,t,n,r,...i){let a=[n,r,...i].map(Tm);if(a.some(e=>!e))return e;let o=e=>a.every(t=>Om(e,t)>=3)&&Om(jm(e),e)>=4.5,s=t?`#ffffff`:`#000000`,c=t?.05:.04,l=e;for(let t=1;t*c<=1&&!o(l);t++)l=Em(e,s,t*c);return l}let Nm=[[`藍`,`#2457d6`],[`靛`,`#5b4fd6`],[`紫`,`#864ad1`],[`桃紅`,`#ba3873`],[`紅`,`#c53228`],[`橘`,`#ab5101`],[`綠`,`#077b42`],[`青`,`#027874`]];function Pm(e,t=!1){if(!/^#[0-9a-fA-F]{6}$/.test(e))return!1;e=e.toLowerCase();let n=document.documentElement,r=n.getAttribute(`data-theme`)===`dark`,i=getComputedStyle(n),a=Tm(i.getPropertyValue(`--surface`))??(r?`#393530`:`#ffffff`),o=Tm(i.getPropertyValue(`--bg`))??(r?`#2f2a25`:`#fcfbfb`),s=Tm(i.getPropertyValue(`--surface-sub`))??(r?`#443f3b`:`#f6f5f4`),c=Tm(i.getPropertyValue(`--surface-chrome`))??(r?`#3d3834`:`#ffffff`),l=r?Em(a,e,.22):Em(`#ffffff`,e,.12),u=km(e,r,o,a,s,c,l),d=Mm(e,r,o,a,s,c,l),f=r?`#ffffff`:`#000000`,p={"--accent":d,"--accent-hover":Em(d,f,.12),"--accent-press":Em(d,f,.22),"--accent-soft":l,"--accent-text":u,"--on-accent":jm(d),"--focus":u,"--focus-ring":u};for(let[e,t]of Object.entries(p))n.style.setProperty(e,t);return t||I(gm,e),!0}let Fm=!1;function Im(){xm(vm()),yi(),Fm||typeof window.matchMedia!=`function`||(Fm=!0,window.matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,()=>{vm()===`auto`&&xm(`auto`)}))}function Lm(e,t){let n=e.trim();/^[a-z][a-z0-9-]*$/.test(n)&&typeof document<`u`&&(n=getComputedStyle(t??document.documentElement).getPropertyValue(`--`+n));let r=Tm(n);return r?Om(r,`#171512`)>=Om(r,`#ffffff`)?`#171512`:`#ffffff`:`#171512`}function Rm(e,t,n){let r=n>t?(e-t)/(n-t):0;return`heat-${Math.min(7,Math.max(1,Math.round(r*6)+1))}`}function zm(e,t){let n=Math.abs(e);if(n<=t.zero)return`diverge-zero`;let r=n>=t.strong;return e<0?r?`diverge-neg-strong`:`diverge-neg`:r?`diverge-pos-strong`:`diverge-pos`}qe(),ti(Ke);let Bm=Nm,Vm=/^#[0-9a-fA-F]{6}$/;function Hm({value:e,onChange:t,label:n,className:r}){let[i,a]=y.useState(()=>(e||Cm()).toLowerCase()),[o,s]=y.useState(``),c=(e||i).toLowerCase(),l=e=>{a(e),t?t(e):Pm(e)},u=!!o&&!Vm.test(o),d=y.useRef([]),f=Math.max(0,Bm.findIndex(([,e])=>e===c));return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-accentpick`,r),children:[/* @__PURE__ */ (0,A.jsx)(`div`,{role:`radiogroup`,"aria-label":n||w(`強調色`),className:`ui-accentpick-swatches`,children:Bm.map(([e,t],n)=>{let r=c===t;return/* @__PURE__ */ (0,A.jsx)(`button`,{ref:e=>{d.current[n]=e},type:`button`,role:`radio`,"aria-checked":r,tabIndex:n===f?0:-1,"aria-label":w(e),title:w(e),className:M(`ui-swatch`,r&&`is-on`),style:{background:t,color:t},onClick:()=>{s(``),l(t)},onKeyDown:e=>{if(W(e))return;let t=Bm.length,r=e.key===`ArrowRight`||e.key===`ArrowDown`?(n+1)%t:e.key===`ArrowLeft`||e.key===`ArrowUp`?(n-1+t)%t:-1;r<0||(e.preventDefault(),d.current[r]?.focus(),s(``),l(Bm[r][1]))},children:r?/* @__PURE__ */ (0,A.jsx)(Y,{name:`check`,size:14}):null},t)})}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-accentpick-hex`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-accentpick-preview`,style:{background:!u&&o?o:c}}),/* @__PURE__ */ (0,A.jsx)(`input`,{className:M(`ui-input`,u&&`is-invalid`),"aria-label":w(`自訂強調色(色碼)`),"aria-invalid":u||void 0,value:o,placeholder:c,onChange:e=>{let t=e.target.value.trim();s(t),Vm.test(t)&&l(t.toLowerCase())}}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-field-hint`,u&&`is-error`),children:w(u?`色碼格式不正確,例如 #2457d6`:`輸入 # 加 6 碼`)})]})]})}let Um=()=>!document.activeElement||document.activeElement===document.body;function Wm(e){let t=y.useRef(null),n=y.useRef(!1);y.useEffect(()=>{if(e&&!n.current){let e=document.activeElement;t.current=e instanceof HTMLElement&&e!==document.body?e:null}if(!e&&n.current){let r=t.current;t.current=null;let i=document.activeElement,a=performance.now()+2e3,o=0,s=()=>{if(Um()){r?.isConnected?r.focus():cm();return}let e=document.activeElement;!(e===i||e?.closest(`[data-ending-style]`))||performance.now()>a||(o=requestAnimationFrame(s))};return o=requestAnimationFrame(s),n.current=e,()=>cancelAnimationFrame(o)}n.current=e},[e])}function Gm(e,t){let n=y.useRef(t);y.useEffect(()=>{n.current=t}),y.useEffect(()=>{let t=e.current;if(!t)return;let r=null,i=-1,a=()=>Array.from(t.querySelectorAll(`button:not([disabled]), a[href], [tabindex]:not([tabindex="-1"]), input:not([disabled]), [role="tab"]`)).filter(e=>e.getClientRects().length>0&&!e.matches(`:disabled`)),o=e=>{e.target instanceof HTMLElement&&(r=e.target,i=a().indexOf(r))},s=()=>{let e=a(),t=n.current?.()??e[Math.min(i,e.length-1)]??null;r=null,t?t.focus():cm()},c=0,l=new MutationObserver(()=>{if(!r||r.isConnected&&!r.matches(`:disabled`))return;if(Um())return s();let e=r;cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=requestAnimationFrame(()=>{r===e&&(Um()||document.activeElement===e)&&s()})})});return t.addEventListener(`focusin`,o),l.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`disabled`]}),()=>{t.removeEventListener(`focusin`,o),l.disconnect(),cancelAnimationFrame(c)}},[e])}let Km=/*#__PURE__*/ y.createContext(void 0);function qm(e){let t=y.useContext(Km);if(t===void 0&&!e)throw Error(Pi(33));return t}let Jm=/*#__PURE__*/ y.createContext(void 0);function Ym(e){let t=y.useContext(Jm);if(t===void 0&&!e)throw Error(Pi(36));return t}let Xm=/*#__PURE__*/ y.createContext(void 0);function Zm(e=!0){let t=y.useContext(Xm);if(t===void 0&&!e)throw Error(Pi(25));return t}function Qm({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=y.useRef(e!==void 0),[a,o]=y.useState(()=>t);return[i&&e!==void 0?e:a,y.useCallback(e=>{i||o(e)},[])]}let $m=/*#__PURE__*/ y.createContext(null);function eh(e=`root`){let t=y.useContext($m),n=y.useContext(Jm);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}let th={visible:!0,ref:null};function nh(){return th}function rh(e,t,n=`root`){let r=eh(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??nh)({label:e.label,children:e.children,render:e.render}),a=Fo(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}let ih=/*#__PURE__*/ y.createContext(void 0);function ah(e){e.preventDefault()}function oh(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=Ym(),u=Zm(!0),d=c.type===`submenu-trigger`,f=d?l.parentVirtualFocus:l.virtualFocus,p=(d&&l.parent.type===`menu`?l.parent.store:l.store).useState(`webkitAriaSelected`,n),{events:m}=a.useState(`floatingTreeRoot`),h=a.useState(`open`),g=u!==void 0,_=!f&&h&&n?0:-1;return y.useMemo(()=>({id:r,role:`menuitem`,tabIndex:_,"aria-selected":p,onMouseDown:f?ah:void 0,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&m.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&m.emit(`close`,{domEvent:e.nativeEvent,reason:_o})},onMouseUp(e){if(u){let t=u.initialCursorPointRef.current;if(u.initialCursorPointRef.current=null,g&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||g&&!Yi&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&fp(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}let sh={type:`regular-item`};function ch(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=y.useRef(null),{getButtonProps:d,buttonRef:f}=pp({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=oh({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=y.useCallback(e=>Fc(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=Fo(u,f);return y.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}let lh=/*#__PURE__*/ y.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function uh(){return y.useContext(lh)}function dh(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=uh(),u=y.useRef(-1),[d,f]=y.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=y.useRef(null),h=y.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return X(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}let fh={checked(e){return e?{"data-checked":``}:{"data-unchecked":``}},...Ba},ph=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!1,checked:l=!1,onCheckedChange:u,style:d,...f}=e,{store:p}=Ym(),m=dh({guess:!0,label:a}),h=_f(i),g=p.useState(`disabled`),_=p.useState(`isActive`,m.index),v=p.useState(`floatingNodeId`),b=p.useState(`itemProps`),x=s||g,{getItemProps:S,itemRef:C}=ch({closeOnClick:c,disabled:x,highlighted:_,id:h,store:p,nativeButton:o,nodeId:v,itemMetadata:sh}),w=y.useMemo(()=>({disabled:x,highlighted:_,checked:l}),[x,_,l]);function T(e){let t=Q(_o,e.nativeEvent,void 0,{preventUnmountOnClose:Ai});u?.(!l,t)}let E=Jc(`div`,e,{state:w,stateAttributesMapping:fh,props:[b,{role:`menuitemcheckbox`,"aria-checked":l,onClick:T},f,S],ref:[C,t,m.ref]});return/*#__PURE__*/ (0,A.jsx)(ih.Provider,{value:w,children:E})}),mh=/*#__PURE__*/ y.forwardRef(function(e,t){let{checked:n,defaultChecked:r,onCheckedChange:i,...a}=e,[o,s]=Qm({controlled:n,default:r??!1,name:`MenuCheckboxItem`,state:`checked`}),c=rh(e,t);function l(e,t){i?.(e,t),t.isCanceled||s(e)}return c.visible?/*#__PURE__*/ (0,A.jsx)(ph,{...a,checked:o,onCheckedChange:l,ref:c.ref}):null}),hh=/*#__PURE__*/ y.createContext(void 0);function gh(){let e=y.useContext(hh);if(e===void 0)throw Error(Pi(31));return e}let _h=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=y.useState(void 0),c=Jc(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return/*#__PURE__*/ (0,A.jsx)(hh.Provider,{value:s,children:c})}),vh=/*#__PURE__*/ y.forwardRef(function(e,t){let n=eh()?.Group??_h;return/*#__PURE__*/ (0,A.jsx)(n,{...e,ref:t})}),yh=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=_f(a),c=gh();return X(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),Jc(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),bh=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,{store:d}=Ym(),f=dh({guess:!0,label:a}),p=_f(i),m=d.useState(`disabled`),h=d.useState(`isActive`,f.index),g=d.useState(`floatingNodeId`),_=d.useState(`itemProps`),v=s||m,{getItemProps:y,itemRef:b}=ch({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:sh});return Jc(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),xh=/*#__PURE__*/ y.forwardRef(function(e,t){let n=rh(e,t);return n.visible?/*#__PURE__*/ (0,A.jsx)(bh,{...e,ref:n.ref}):null}),Sh=/*#__PURE__*/ y.createContext(void 0);function Ch(e){let t=y.useContext(Sh);if(t===void 0&&!e)throw Error(Pi(69));return t}let wh=/*#__PURE__*/ y.createContext(void 0);function Th(){return y.useContext(wh)}function Eh(e,t){let n=Qc(e.render);if(/*#__PURE__*/ y.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function Dh(e,t,n){let r=Eh(e,t),i=r===t?void 0:r;return[r,y.useCallback(e=>n?.(e?i:void 0),[i,n])]}function Oh(e,t,n){let r=Qc(e.render),i=/*#__PURE__*/ y.isValidElement(r)?r.props:void 0,a=e[`aria-label`]??i?.[`aria-label`],o=e[`aria-labelledby`]??i?.[`aria-labelledby`];return o==null&&!a&&(o=t?t.id||void 0:n||void 0),o}let kh=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,id:o,initialFocus:s,...c}=e,{store:l,defaultFloatingId:u,setRenderedFloatingId:d,virtualFocus:f,orientation:p}=Ym(),m=Th(),{side:h,align:g}=qm(),_=Ch(!0)!=null,v=l.useState(`open`),b=l.useState(`transitionStatus`),x=l.useState(`popupProps`),S=l.useState(`mounted`),C=l.useState(`instantType`),w=l.useState(`activeTriggerElement`),T=l.useState(`parent`),E=l.useState(`lastOpenChangeReason`),D=l.useState(`rootId`),O=l.useState(`floatingRootContext`),k=l.useState(`floatingTreeRoot`),j=l.useState(`closeDelay`),M=l.useState(`hoverEnabled`),N=l.useState(`disabled`),P=l.useState(`openMethod`),F=l.useState(`activeTriggerId`),I=l.useState(`listElement`),[L,R]=Dh(e,u,d),z=Oh(e,w,F),B=T.type===`menu`?m:void 0,V=T.type===`context-menu`,H=s??T.type!==`menu`;s===void 0&&I&&T.type!==`menu`&&(H=()=>l.state.activeIndex===null&&I),Ql({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),y.useEffect(()=>{function e(e){l.setOpen(!1,Q(e.reason,e.domEvent))}return k.events.on(`close`,e),()=>{k.events.off(`close`,e)}},[k.events,l]),Ku(O,{enabled:M&&!N&&!V&&T.type!==`menubar`,closeDelay:j});let U=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:ee,handleFocus:te}=(y.useContext($m)?.useParentHandoff??jh)(l,T,v,f),ne=Jc(`div`,e,{state:{transitionStatus:b,side:h,align:g,open:v,nested:T.type===`menu`,instant:C},ref:[t,l.context.popupRef,U,R],stateAttributesMapping:Xa,props:[x,{id:L,...I?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":z},onKeyDown(e){B?.onPopupKeyDown?.(e),_&&yp.has(e.key)&&e.stopPropagation()},onFocus:te},Uf(b),c,{"data-rootownerid":D}]}),W=T.type===void 0||V;(w||T.type===`menubar`&&E!==`outside-press`)&&(W=!0);let re=B?.getReturnElement??ee;return/*#__PURE__*/ (0,A.jsx)(Ol,{context:O,openInteractionType:P,modal:V,disabled:!S,returnFocus:a??re??W,explicitReturnFocus:a===void 0&&re?!1:void 0,initialFocus:H,restoreFocus:!0,getInsideElements:T.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:T.type===`menubar`?void 0:k,previousFocusableElement:w,nextFocusableElement:T.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:ne})}),Ah={parentVirtualFocusRef:void 0,handleFocus:void 0};function jh(){return Ah}let Mh=/*#__PURE__*/ y.forwardRef(function(e,t){let n=eh()?.Popup??kh;return/*#__PURE__*/ (0,A.jsx)(n,{...e,ref:t})}),Nh=/*#__PURE__*/ y.createContext(void 0);function Ph(){let e=y.useContext(Nh);if(e===void 0)throw Error(Pi(32));return e}let Fh=/*#__PURE__*/ y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=Ym();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return/*#__PURE__*/ (0,A.jsx)(Nh.Provider,{value:n,children:/*#__PURE__*/ (0,A.jsx)(ul,{ref:t,...r,portalOwnerRole:o})})});function Ih(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=$(i),[,o]=y.useState(0),s=Si(Rh).current,c=Si(Lh).current,l=y.useRef(0),u=y.useRef(!0),d=y.useRef(null),f=y.useRef(null),p=$(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=$((e,t)=>{c.set(e,t),p()}),h=$(e=>{c.delete(e),p()}),g=$(e=>{let t=/* @__PURE__ */ new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!Vh(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&Hh(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=/* @__PURE__ */ new Set;for(let t=1;t<e.length;t+=1){let r=Bh(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=$(()=>{let[e,t]=zh(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});X(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),X(()=>{u.current&&v()}),X(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let b=$(e=>(s.add(e),()=>{s.delete(e)})),x=y.useMemo(()=>({register:m,unregister:h,subscribeMapChange:b,nextIndexRef:l}),[m,h,b,l]);return/*#__PURE__*/ (0,A.jsx)(lh.Provider,{value:x,children:t})}function Lh(){return/* @__PURE__ */ new Map}function Rh(){return/* @__PURE__ */ new Set}function zh(e){let t=/* @__PURE__ */ new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>Hh(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function Bh(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function Vh(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function Hh(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function Uh(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=y.useRef(null),o=y.useRef(null),s=Zl(r);X(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),X(()=>{let e=n,r=a.current;if(e&&(a.current=e),!r||!e||e===r||!t.select(`open`))return;t.set(`instantType`,void 0);let i=new AbortController;return o.current=i,s(()=>{t.select(`open`)&&t.set(`instantType`,`trigger-change`)},i.signal),()=>{i.abort()}},[n,s,t])}function Wh(e,t,n,r){let[i,a]=y.useState(!1);X(()=>{if(!e||!t||n==null){a(!1);return}let r=Zo(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-20)},[e,t,n]),Pp(e&&(!t||i),r)}let Gh=/*#__PURE__*/ y.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=rl,style:g,..._}=e,{store:v,virtualFocus:b,syncHighlightedItem:x}=Ym(),S=Ph(),C=Zm(!0),w=v.useState(`parent`),T=v.useState(`floatingRootContext`),E=v.useState(`floatingTreeRoot`),D=v.useState(`mounted`),O=v.useState(`open`),k=v.useState(`modal`),j=v.useState(`openMethod`),M=v.useState(`activeTriggerElement`),N=v.useState(`transitionStatus`),P=v.useState(`positionerElement`),F=v.useState(`instantType`),I=v.useState(`adaptiveOrigin`),L=v.useState(`lastOpenChangeReason`),R=v.useState(`floatingNodeId`),z=v.useState(`floatingParentNodeId`),B=T.useState(`domReferenceElement`),V=n,H=c,U=l,ee=s,te=h;w.type===`context-menu`&&(V=n??w.context?.anchor,ee??=`start`,!o&&ee!==`center`&&(U=e.alignOffset??2,H=e.sideOffset??-5));let ne=o,W=ee;w.type===`menu`?(ne??=`inline-end`,W??=`start`,te=e.collisionAvoidance??il):w.type===`menubar`&&(ne??=w.context.orientation===`vertical`?`inline-end`:`bottom`,W??=`start`);let re=w.type===`context-menu`,ie=Bf({anchor:V,floatingRootContext:T,positionMethod:C?`fixed`:r,mounted:D,side:ne,sideOffset:H,align:W,alignOffset:U,arrowPadding:re?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:R,keepMounted:S,disableAnchorTracking:m,collisionAvoidance:te,shift:re?{crossAxis:!(`side`in te&&te.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:E,adaptiveOrigin:I,lazyFlip:b?`placement`:!1});y.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===R&&v.set(`hoverEnabled`,!1),e.nodeId!==R&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,Q(Oo)))}return E.events.on(`menuopenchange`,e),()=>{E.events.off(`menuopenchange`,e)}},[v,E.events,R]),y.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,Q(t))}return E.events.on(`menuopenchange`,e),()=>{E.events.off(`menuopenchange`,e)}},[E.events,v]);let G=zi();y.useEffect(()=>{O||G.clear()},[O,G]),y.useEffect(()=>{function e(e){if(O&&e.nodeId===v.select(`floatingParentNodeId`)){if(e.target&&M&&M!==e.target){let e=v.select(`closeDelay`);e>0?G.isStarted()||G.start(e,()=>{v.setOpen(!1,Q(Oo))}):v.setOpen(!1,Q(Oo))}else G.clear()}}return E.events.on(`itemhover`,e),()=>{E.events.off(`itemhover`,e)}},[E.events,O,M,v,G]),y.useEffect(()=>{let e={open:O,nodeId:R,parentNodeId:z,reason:v.select(`lastOpenChangeReason`)};E.events.emit(`menuopenchange`,e)},[E.events,O,v,R,z]),Uh({store:v,domReference:B,positionerElement:P,open:O});let K={open:O,side:ie.side,align:ie.align,anchorHidden:ie.anchorHidden,nested:w.type===`menu`,instant:F},q=w.type===`menubar`&&w.context.modal;Wh(O&&(q||k&&L!==`trigger-hover`),j===`touch`,P,M);let ae=Wf(e,K,{styles:ie.positionerStyles,transitionStatus:N,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!D,inert:!O}),oe=D&&w.type!==`menu`&&(w.type!==`menubar`&&k&&L!==`trigger-hover`||w.type===`menubar`&&w.context.modal),se=null;return w.type===`menubar`?se=w.context.contentElement:w.type===void 0&&(se=M),/*#__PURE__*/ (0,A.jsxs)(Km.Provider,{value:ie,children:[oe&&/*#__PURE__*/ (0,A.jsx)(Sp,{ref:w.type===`context-menu`||w.type===`nested-context-menu`?w.context.internalBackdropRef:null,inert:Jf(!O),cutout:se}),/*#__PURE__*/ (0,A.jsx)(vl,{id:R,children:/*#__PURE__*/ (0,A.jsx)(Ih,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:x,children:ae})})]})}),Kh=/*#__PURE__*/ y.createContext(void 0);function qh(){let e=y.useContext(Kh);if(e===void 0)throw Error(Pi(34));return e}let Jh=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,value:i,defaultValue:a,onValueChange:o,disabled:s=!1,style:c,"aria-labelledby":l,...u}=e,[d,f]=y.useState(void 0),[p,m]=Qm({controlled:i,default:a,name:`MenuRadioGroup`}),h=$((e,t)=>{o?.(e,t),t.isCanceled||m(e)}),g=Jc(`div`,e,{state:{disabled:s},ref:t,props:{role:`group`,"aria-labelledby":l??d,"aria-disabled":s||void 0,...u}}),_=y.useMemo(()=>({value:p,setValue:h,disabled:s}),[p,h,s]);return/*#__PURE__*/ (0,A.jsx)(hh.Provider,{value:f,children:/*#__PURE__*/ (0,A.jsx)(Kh.Provider,{value:_,children:g})})}),Yh=/*#__PURE__*/ y.memo(/*#__PURE__*/ y.forwardRef(function(e,t){let n=eh()?.RadioGroup??Jh;return/*#__PURE__*/ (0,A.jsx)(n,{...e,ref:t})})),Xh=/*#__PURE__*/ y.createContext(void 0);function Zh(){let e=y.useContext(Xh);if(e===void 0)throw Error(Pi(35));return e}let Qh=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!1,value:l,style:u,...d}=e,{store:f}=Ym(),{value:p,setValue:m,disabled:h}=qh(),g=dh({guess:!0,label:a}),_=_f(i),v=f.useState(`isActive`,g.index),b=f.useState(`floatingNodeId`),x=f.useState(`itemProps`),S=f.useState(`disabled`),C=s||h||S,w=p===l,{getItemProps:T,itemRef:E}=ch({closeOnClick:c,disabled:C,highlighted:v,id:_,store:f,nativeButton:o,nodeId:b,itemMetadata:sh}),D=y.useMemo(()=>({disabled:C,highlighted:v,checked:w}),[C,v,w]);function O(e){let t=Q(_o,e.nativeEvent,void 0,{preventUnmountOnClose:Ai});m(l,t)}let k=Jc(`div`,e,{state:D,stateAttributesMapping:fh,props:[x,{role:`menuitemradio`,"aria-checked":w,onClick:O},d,T],ref:[E,t,g.ref]});return/*#__PURE__*/ (0,A.jsx)(Xh.Provider,{value:D,children:k})}),$h=/*#__PURE__*/ y.forwardRef(function(e,t){let n=rh(e,t);return n.visible?/*#__PURE__*/ (0,A.jsx)(Qh,{...e,ref:n.ref}):null}),eg=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=Zh(),c=y.useRef(null),{transitionStatus:l,mounted:u,setMounted:d}=ql(s.checked);return Ql({batch:!0,enabled:!s.checked,open:s.checked,ref:c,onComplete(){s.checked||d(!1)}}),Jc(`span`,e,{state:{checked:s.checked,disabled:s.disabled,highlighted:s.highlighted,transitionStatus:l},stateAttributesMapping:fh,ref:[t,c],props:{"aria-hidden":!0,...o},enabled:a||u})}),tg=/*#__PURE__*/ y.createContext(null);function ng(e){let t=y.useContext(tg);if(t===null&&!e)throw Error(Pi(5));return t}function rg(e){return e==null?po:e.type.startsWith(`key`)?To:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?Eo:po}let ig={...Iu,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,keyboardOpen:e=>e.keyboardOpen,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,listElement:e=>e.listElement,triggerControlsId:(e,t)=>{let n=Iu.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>Zi&&e.inputFocused&&t?!0:void 0,highlightedItemId:e=>e.highlightedItem?.id||void 0,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType===`trigger-change`&&!Iu.open(e)?void 0:e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}};var ag=class extends Du{constructor(e,t,n=!1){let r=new mu,i=sg(r,t,n,e);super(i,og(r),ig),this.observe(`parent`,e=>{e.type===`menu`?this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef:e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef)})}subscribeToParentMenu(){let e=this.state.parent;if(e.type!==`menu`)return;let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);return e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}setActiveIndex(e,t,n){if(this.state.activeIndex!==e){let r=(e===null?void 0:this.context.itemDomElements.current[e])===this.context.reportedItem;this.context.highlightReason=r?`none`:t,this.context.highlightEvent=r?void 0:n}this.set(`activeIndex`,e)}highlightItem(e,t,n){let r=this.context.itemDomElements.current.indexOf(e);r>-1&&this.setActiveIndex(r,t,n)}};function og(e){return{positionerRef:/*#__PURE__*/ y.createRef(),popupRef:/*#__PURE__*/ y.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:/*#__PURE__*/ y.createRef(),beforeTriggerFocusGuardRef:/*#__PURE__*/ y.createRef(),beforeContentFocusGuardRef:/*#__PURE__*/ y.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function sg(e,t,n=!1,r){return{...Au(e,t,n),disabled:!1,modal:!0,openMethod:null,keyboardOpen:!1,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,listElement:null,filterTriggerProps:Mi,inputProps:Mi,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new fl,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Mi,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}let cg=/*#__PURE__*/ y.createContext(null);function lg(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function ug(e,t){return e===`list-navigation`||lg(e,t)}let dg=Di(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,onItemHighlighted:a,defaultOpen:o=!1,disabled:s=!1,modal:c,loopFocus:l=!0,orientation:u=`vertical`,actionsRef:d,closeParentOnEsc:f=!1,handle:p,triggerId:m,defaultTriggerId:h=null,highlightItemOnHover:g=!0,isSubmenu:_=!1,virtualFocus:v=!1,virtualFocusRef:b,allowEscape:x=!0,resetOnPointerLeave:S=!0}=e,C=Zm(!0),w=Ym(!0),T=ng(!0),E=w?.store,D=w?.virtualFocus??!1,O=y.useMemo(()=>_&&E?{type:`menu`,store:E}:T?{type:`menubar`,context:T}:C&&!E?{type:`context-menu`,context:C}:{type:void 0},[C,E,T,_]),k=_f(),j=_f(),[M,N]=y.useState(void 0),P=(M??j)||void 0,F=hl(),I=O.type===`menu`?O.store:void 0,L=(n??o)&&I?.state.transitionStatus===`starting`,R=Si(()=>L?I?.state.instantType:void 0).current,z=Si(()=>{let e=new ag({open:o,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:O,disabled:s,highlightItemOnHover:g,modal:O.type===void 0?c:void 0,rootId:k,instantType:R},P,F!=null);return e.context.virtualFocusRef=b,e}).current;z.useControlledProp(`openProp`,n),z.useControlledProp(`triggerIdProp`,m),z.useContextCallback(`onOpenChangeComplete`,i);let B=z.useState(`floatingTreeRoot`),V=_l(B),H=z.useState(`open`),U=z.useState(`activeTriggerElement`),ee=z.useState(`positionerElement`),te=z.useState(`hoverEnabled`),ne=z.useState(`disabled`),W=z.useState(`lastOpenChangeReason`),re=z.useState(`parent`),ie=z.useState(`activeIndex`),G=z.useState(`keyboardOpen`),K=z.useState(`payload`),q=z.useState(`floatingParentNodeId`),ae=y.useRef(null),oe=y.useRef(re.type!==`context-menu`),se=zi(),ce=y.useRef(!0),le=zi(),J=q!=null,{openMethod:ue,triggerProps:de}=qp(H);z.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:re.type===void 0?c:void 0,openMethod:ue,rootId:k}),uu(z);let{forceUnmount:fe,transitionStatus:pe}=du(H,z,()=>{z.set(`allowMouseEnter`,!1)},L),me=Zl(z.context.popupRef);y.useEffect(()=>{if(R===void 0)return;let e=()=>{z.state.instantType===R&&z.set(`instantType`,void 0)};if(!H){e();return}if(pe!==void 0)return;if(z.context.popupRef.current==null){e();return}let t=new AbortController;return me(e,t.signal),()=>{t.abort()}},[R,H,pe,me,z]),X(()=>{C&&!w?z.update({parent:{type:`context-menu`,context:C},floatingNodeId:V,floatingParentNodeId:F}):(w||!z.select(`activeTriggerElement`))&&z.update({floatingNodeId:V,floatingParentNodeId:F})},[C,w,V,F,U,z]),y.useEffect(()=>{H||(ae.current=null),re.type===`context-menu`&&(H?se.start(500,()=>{oe.current=!0}):(se.clear(),oe.current=!1))},[se,H,re.type]),X(()=>{!H&&!te&&z.set(`hoverEnabled`,!0)},[H,te,z]);let he=$((e,t)=>{let n=t.reason;if(!e&&!z.select(`open`)||H===e&&t.trigger===U&&W===n)return;let i=su(t);if(!e&&t.trigger==null&&(t.trigger=U??void 0),r?.(e,t),t.isCanceled)return;z.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!ce.current)return;e&&n===`trigger-focus`?(ce.current=!1,le.start(300,()=>{ce.current=!0})):(ce.current=!0,le.clear());let o=!e&&(n===`escape-key`||n==null);ae.current=t.event;let s=ou(z.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&ug(n,a),s.instantType=re.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:lg(n,a)?`click`:o?`dismiss`:void 0,z.update(s)}),ge=Kl({popupStore:z,floatingRootContext:z.state.floatingRootContext,floatingId:P,nested:F!=null,onOpenChange:he}),_e=ge.context.events;X(()=>{let e=({open:e,eventDetails:t})=>he(e,t);return _e.on(`setOpen`,e),()=>{_e?.off(`setOpen`,e)}},[_e,he]),X(()=>z.subscribeToParentMenu(),[z]);let ve=y.useCallback(()=>{z.setOpen(!1,Q(ko))},[z]);y.useImperativeHandle(d,()=>({unmount:fe,close:ve}),[fe,ve]);let ye;re.type===`context-menu`&&(ye=re.context),y.useImperativeHandle(ye?.positionerRef,()=>ee,[ee]),y.useImperativeHandle(ye?.actionsRef,()=>({setOpen:he}),[he]);let be=Fl(ge,{enabled:!ne,bubbles:{escapeKey:f&&re.type===`menu`},outsidePress(){return re.type!==`context-menu`||ae.current?.type===`contextmenu`||oe.current},externalTree:J?B:void 0}),xe=jf(),Se=td(ge,{enabled:!ne,listRef:z.context.itemDomElements,activeIndex:ie,virtual:v,nested:re.type===`menubar`||!v&&re.type!==void 0,parentOrientation:re.type===`menubar`?re.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?G:void 0,allowEscape:v&&l&&x,orientation:u,triggerOrientation:v?`vertical`:u,rtl:xe===`rtl`,disabledIndices:ji,onNavigate(e,t){z.setActiveIndex(e,rg(t),t?.nativeEvent)},openOnArrowKeyDown:re.type!==`context-menu`&&!(v&&_),externalTree:!v&&J?B:void 0,nestedReturnFocusRef:I?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:S}),Ce=y.useCallback(e=>{z.context.typingRef.current=e},[z]),we=nd(ge,{enabled:!ne&&!v,listRef:z.context.itemLabels,elementsRef:z.context.itemDomElements,activeIndex:ie,resetMs:500,onMatch:(e,t)=>{H&&e!==ie&&z.setActiveIndex(e,To,t.nativeEvent)},onTyping:Ce}),Te=$(a),Ee=y.useRef(-1),De=$(()=>{let e=z.state.activeIndex,t=e===null?void 0:z.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(Ee.current===n&&z.context.reportedItem===t)return;Ee.current=n,z.context.reportedItem=t,v&&z.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=z.context;z.context.highlightReason=po,z.context.highlightEvent=void 0,a&&Te(t,fo(r,i,{label:t===void 0?void 0:z.context.itemLabels.current[n]??void 0}))});X(()=>{De()},[ie,De]);let Oe=y.useMemo(()=>{if(!v)return Se.reference;if(!Se.trigger)return Mi;let{onFocus:e,...t}=Se.trigger;return t},[v,Se.reference,Se.trigger]);z.useSyncedValue(`inputProps`,v?Se.reference??Mi:Mi);let ke=y.useMemo(()=>{let e=Fc(we.reference,Oe,be.reference,{onMouseMove(){z.set(`allowMouseEnter`,!0)}},de);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=H,e},[z,we.reference,Oe,be.reference,de,H]),Ae=y.useMemo(()=>{let e=Fc(Se.trigger,be.trigger,de);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[Se.trigger,be.trigger,de]);Si(()=>(z.update({inactiveTriggerProps:Ae}),null)),fu(z,{floatingRootContext:ge,activeTriggerProps:ke,inactiveTriggerProps:Ae,popupProps:y.useMemo(()=>Fc(eu,{onMouseMove(){z.set(`allowMouseEnter`,!0),re.type===`menu`&&z.set(`hoverEnabled`,!1)},onClick(){z.select(`hoverEnabled`)&&z.set(`hoverEnabled`,!1)},onKeyDown(e){let t=z.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},we.floating,Se.floating,be.floating),[re.type,z,we.floating,Se.floating,be.floating]),itemProps:Se.item??Mi});let je=y.useMemo(()=>({store:z,parent:O,orientation:u,loopFocus:l,allowEscape:x,defaultFloatingId:j,setRenderedFloatingId:N,virtualFocus:v,parentVirtualFocus:D,syncHighlightedItem:De}),[z,O,u,l,x,j,v,D,De]),Me=typeof t==`function`?t({payload:K}):t,Ne=/*#__PURE__*/ (0,A.jsxs)(Jm.Provider,{value:je,children:[p&&/*#__PURE__*/ (0,A.jsx)(ru,{handle:p,store:z}),Me]});return(re.type===void 0||re.type===`context-menu`)&&(Ne=/*#__PURE__*/ (0,A.jsx)(yl,{externalTree:B,children:Ne})),Ne});function fg(e){let t=y.useContext(cg);if(t===null)return/*#__PURE__*/ (0,A.jsx)(dg,{...e});let n=t.Root;return/*#__PURE__*/ (0,A.jsx)(cg.Provider,{value:null,children:/*#__PURE__*/ (0,A.jsx)(n,{...t.options,...e})})}let pg={};function mg(e){Ym();let t=y.useContext(cg);if(t!==null){let n=t.SubmenuRoot;return/*#__PURE__*/ (0,A.jsx)(cg.Provider,{value:null,children:/*#__PURE__*/ (0,A.jsx)(n,{...t.options,...e})})}return/*#__PURE__*/ (0,A.jsx)(wh.Provider,{value:pg,children:/*#__PURE__*/ (0,A.jsx)(dg,{...e,isSubmenu:!0})})}function hg(e,t){let n=gg(t);return e.clientX>=n.left-5&&e.clientX<=n.right+5&&e.clientY>=n.top-5&&e.clientY<=n.bottom+5}function gg(e){let t=e.getBoundingClientRect(),n=la(e);if(ea)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}function _g(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=up(),{ref:i,index:a}=dh(e),o=n===a,s=y.useRef(null),c=Fo(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function vg(e){let{render:t,className:n,style:r,state:i=Mi,props:a=ji,refs:o=ji,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=_g({metadata:s});return Jc(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function yg(e){if(pa(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!Ta(e))return yg(Oa(e))}function bg(e,t){function n(n,r,i){let a=n.currentTarget;b.flushSync(()=>{e.setOpen(!1,Q(So,n.nativeEvent,a))}),rc(a.isConnected?a:t.current,r,i)?.focus()}function r(t){n(t,-1,e.select(`positionerElement`))}function i(t){let r=e.select(`positionerElement`);r&&ic(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function xg(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=y.useRef(!1);return y.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,Zo(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:Mi,[t,n,r])}let Sg=Oi(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=Ym(!0),h=Lu(d)??m?.store;if(!h)throw Error(Pi(85));let g=_f(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),b=h.useState(`isOpenedByTrigger`,g),x=h.useState(`triggerControlsId`,g),S=y.useRef(null),C=wg(),w=up(!0),T=gl(),E=y.useMemo(()=>T??new fl,[T]),{registerTrigger:D,isMountedByThisTrigger:O}=lu(g,S,h,{payload:f,closeDelay:u,parent:C,floatingTreeRoot:E,floatingNodeId:_l(E),floatingParentNodeId:hl(),keyboardEventRelay:w?.relayKeyboardEvent}),k=C.type===`menubar`,j=h.useState(`disabled`),M=a||j||k&&C.context.disabled,{getButtonProps:N,buttonRef:P}=pp({disabled:M,native:o});y.useEffect(()=>{!b&&C.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,b,C.type]);let F=y.useRef(null),I=zi(),L=$(e=>{if(!F.current)return;I.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;Z(F.current,t)||Z(h.select(`positionerElement`),t)||t===F.current||t!=null&&yg(t)===h.select(`rootId`)||hg(e,F.current)||E.events.emit(`close`,{domEvent:e,reason:Do})});y.useEffect(()=>{let e=Zo(F.current);if(b&&h.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,L,{once:!0}),()=>{e.removeEventListener(`mouseup`,L)}},[b,L,h]);let R=k&&C.context.hasSubmenuOpen,z=Ju(v,{enabled:(c??R)&&!M&&(!k||R&&!O),handleClose:cd({blockPointerEvents:!k}),mouseOnly:!0,move:!1,restMs:C.type===void 0?l:void 0,delay:{close:u},triggerElementRef:S,externalTree:E,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),B=Cg(b,h.select(`lastOpenChangeReason`)),V=kl(v,{enabled:!M,event:b&&k?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:C.type===void 0&&B}),H=Bu(v,{enabled:!M&&R}),U=xg({open:b,enabled:k,mouseDownAction:`open`}),ee=y.useMemo(()=>Fc(H.reference,V.reference),[H.reference,V.reference]),te=h.useState(`triggerProps`,O),ne=h.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:W,handleFocusTargetFocus:re}=bg(h,S),ie={disabled:M,open:b},G=[F,t,P,D,S],K=[ee,z??Mi,te,{"aria-haspopup":`menu`,"aria-controls":x,id:g,onMouseDown:e=>{h.select(`open`)||(I.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),Zo(e.currentTarget).addEventListener(`mouseup`,L,{once:!0}))}},ne,k?{role:`menuitem`}:{},U,p,N],q=Jc(`button`,e,{enabled:!k,stateAttributesMapping:Ja,state:ie,ref:G,props:K});return k?/*#__PURE__*/ (0,A.jsx)(vg,{tag:`button`,render:n,className:r,style:i,state:ie,refs:G,props:K,stateAttributesMapping:Ja}):b?/*#__PURE__*/ (0,A.jsxs)(y.Fragment,{children:[/*#__PURE__*/ (0,A.jsx)(ts,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:W},`${g}-pre-focus-guard`),/*#__PURE__*/ (0,A.jsx)(y.Fragment,{children:q},g),/*#__PURE__*/ (0,A.jsx)(ts,{ref:h.context.triggerFocusTargetRef,onFocus:re},`${g}-post-focus-guard`)]}):/*#__PURE__*/ (0,A.jsx)(y.Fragment,{children:q},g)});function Cg(e,t){let n=zi(),[r,i]=y.useState(!1);return X(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function wg(){let e=ng(!0);return y.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}let Tg=/*#__PURE__*/ y.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return Jc(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});function Eg(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}let Dg={"aria-expanded":void 0},Og=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,label:a,id:o,nativeButton:s=!1,openOnHover:c=!0,delay:l=100,closeDelay:u=0,disabled:d=!1,...f}=e,p=Ym(!0);if(p?.parent.type!==`menu`)throw Error(Pi(37));let m=qm(),h=Th(),{store:g,parentVirtualFocus:_}=p,v=p.parent.store,b=dh({guess:!0,label:a}),x=_f(o),S=g.useState(`open`),C=y.useRef(!1),w=g.useState(`positionerElement`),T=g.useState(`floatingRootContext`),E=g.useState(`floatingTreeRoot`),D=g.useState(`triggerPopupId`,x),O=au(x,g),k=$(e=>{O(e);let t=g.select(`activeTriggerElement`);e!==null&&g.select(`open`)&&(t===e||g.select(`activeTriggerId`)==null)&&g.update({activeTriggerId:x??null,activeTriggerElement:e,closeDelay:u})}),A=y.useRef(null),j=y.useCallback(e=>{A.current=e,g.set(`activeTriggerElement`,e)},[g]);X(()=>(k(A.current),()=>k(null)),[k,x,g]),X(()=>{if(!S||!w)return;function e(e){Pa(e)===g.context.beforeContentFocusGuardRef.current&&(C.current=e.relatedTarget===A.current)}return w.addEventListener(`focusout`,e,!0),()=>{C.current=!1,w.removeEventListener(`focusout`,e,!0)}},[S,w,g]),g.useSyncedValue(`closeDelay`,u);let M=g.useState(`disabled`),N=v.useState(`disabled`),P=d||M||N,F=v.useState(`itemProps`),I=v.useState(`isActive`,b.index),L=y.useMemo(()=>({type:`submenu-trigger`,setActive(e){v.select(`highlightItemOnHover`)&&v.setActiveIndex(b.index,Eo,e)}}),[v,b.index]),{getItemProps:R,itemRef:z}=ch({closeOnClick:!1,disabled:P,highlighted:I,id:x,store:g,typingRef:v.context.typingRef,nativeButton:s,itemMetadata:L,nodeId:m?.context.nodeId}),B=Ju(T,{enabled:g.useState(`hoverEnabled`)&&c&&!P,handleClose:cd({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:l,delay:{open:l,close:u},shouldOpen:l>0?()=>v.select(`allowMouseEnter`):void 0,triggerElementRef:A,externalTree:E,isClosing:()=>g.select(`transitionStatus`)===`ending`,guardStaleOpen:!0}),V=kl(T,{enabled:!P,event:`mousedown`,toggle:!0,ignoreMouse:c,stickIfOpen:c}).reference??Mi,H=g.useState(`triggerProps`,!0);delete H.id;let U={disabled:P,highlighted:I,open:S},ee=g.useState(`openMethod`),te=g.useState(`lastOpenChangeReason`)===`list-navigation`||ee===`keyboard`,ne=S&&te&&$i,W=h?.onTriggerKeyDown?{onKeyDown:h.onTriggerKeyDown}:void 0;return Jc(`div`,e,{state:U,stateAttributesMapping:qa,props:[V,B,H,W,F,ne?Dg:void 0,{"aria-controls":D,tabIndex:_||!(S||I)?-1:0,onFocus(e){g.select(`open`)&&C.current&&(C.current=!1,g.setOpen(!1,Q(So,e.nativeEvent)))},onBlur(){I&&v.setActiveIndex(null,po)}},f,R],ref:[t,b.ref,z,k,j]})}),kg=/*#__PURE__*/ y.forwardRef(function(e,t){let n=rh(e,t,`submenu-trigger`);if(!n.visible)return null;let r=n.props?Fc(n.props,e):e;return/*#__PURE__*/ (0,A.jsx)(Og,{...r,ref:n.ref})});function Ag(e){return Array.isArray(e)?e.map(e=>Ag(e)).join(`,`):e==null?``:String(e)}function jg(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function Mg(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function Ng(e){return Mg(e?.[0])}function Pg(e){return Ng(e)?e.flatMap(e=>e.items):e}function Fg(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(Ng(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function Ig(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return jg(e)}function Lg(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?jg(e.value):jg(e)}let Rg=/* @__PURE__ */ new Map;function zg(e={}){let{locale:t,...n}=e,r={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...n},i=`${Ag(t)}|${JSON.stringify(r)}`,a=Rg.get(i);if(a)return a;let o=new Intl.Collator(t,r),s={contains(e,t,n){if(!t)return!0;let r=Ig(e,n);for(let e=0;e<=r.length-t.length;e+=1)if(o.compare(r.slice(e,e+t.length),t)===0)return!0;return!1},startsWith(e,t,n){if(!t)return!0;let r=Ig(e,n);return o.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=Ig(e,n),i=t.length;return r.length>=i&&o.compare(r.slice(r.length-i),t)===0}};return Rg.set(i,s),s}function Bg(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=null;for(;t.nextNode();){let e=t.currentNode;e.nodeValue!==``&&(n=e)}return n}function Vg(e=!0){let t=zi(),n=y.useRef(null);return y.useEffect(()=>{if(!e||Ki)return;let r=n.current;if(r==null)return;let i=Bg(r);if(i==null)return;let a=i.data,o=`${a}⁠`;return i.nodeValue=o,t.start(200,()=>{i.nodeValue===o&&(i.nodeValue=a)}),()=>{t.clear(),i.nodeValue===o&&(i.nodeValue=a)}},[e,n,t]),n}lt(),ti(ct);function Hg({items:e,label:t,icon:n=`dots-three`,align:r=`end`,triggerClassName:i}){let[a,o]=y.useState(null),s=e.filter(e=>!e.danger),c=e.filter(e=>!!e.danger),l=e=>/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[e.icon?/* @__PURE__ */ (0,A.jsx)(fi,{icon:e.icon,size:16}):/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-menu-noicon`}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-menu-label`,children:e.label}),e.shortcut?/* @__PURE__ */ (0,A.jsx)(`kbd`,{className:`ui-menu-kbd`,children:e.shortcut}):null]});return/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsxs)(fg,{children:[/* @__PURE__ */ (0,A.jsx)(Sg,{className:M(`ui-iconbtn`,`ui-menu-trigger`,i),"aria-label":t||w(`更多操作`),children:/* @__PURE__ */ (0,A.jsx)(fi,{icon:n,size:20})}),/* @__PURE__ */ (0,A.jsx)(Fh,{children:/* @__PURE__ */ (0,A.jsx)(Gh,{className:`ui-float`,side:`bottom`,align:r,sideOffset:4,children:/* @__PURE__ */ (0,A.jsxs)(Mh,{className:`ui-menu`,children:[s.map((e,t)=>/* @__PURE__ */ (0,A.jsx)(xh,{disabled:e.disabled,className:`ui-menu-item`,onClick:()=>e.onSelect?.(),children:l(e)},t)),c.length&&s.length?/* @__PURE__ */ (0,A.jsx)(Tg,{className:`ui-menu-sep`}):null,c.map((e,t)=>/* @__PURE__ */ (0,A.jsx)(xh,{disabled:e.disabled,className:`ui-menu-item is-danger`,onClick:()=>o(e),children:l(e)},`d`+t))]})})})]}),c.length?/* @__PURE__ */ (0,A.jsx)(am,{open:!!a,onClose:()=>o(null),title:a?a.confirm?.title??w(`{label}?`,{label:a.label}):``,tone:`danger`,confirmLabel:a?.confirm?.confirmLabel??a?.label??``,onConfirm:()=>{let e=a;o(null),e?.onSelect?.()},children:a?.confirm?.body}):null]})}function Ug({actions:e,className:t}){let n=y.useRef(null);Gm(n);let r=e.find(e=>e.primary)??e.find(e=>!e.danger),i=e.filter(e=>e!==r),a=(e,t,n)=>e.danger?/* @__PURE__ */ (0,A.jsx)(Xp,{variant:`danger`,confirm:e.confirm,icon:e.icon,onClick:e.onClick,disabled:e.disabled,children:e.label},t):/* @__PURE__ */ (0,A.jsx)(Xp,{variant:e===r?`primary`:`secondary`,icon:e.icon,onClick:e.onClick,disabled:e.disabled,className:n?`ui-actbar-main`:void 0,children:e.label},t),o=i.map(e=>e.danger?{label:e.label,icon:e.icon,onSelect:e.onClick,disabled:e.disabled,danger:!0,confirm:e.confirm}:{label:e.label,icon:e.icon,onSelect:e.onClick,disabled:e.disabled});return/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:n,className:M(`ui-actbar`,t),children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-actbar-wide`,children:(r?[r,...i]:i).map((e,t)=>a(e,t,!1))}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-actbar-narrow`,children:[r?a(r,0,!0):null,i.length?/* @__PURE__ */ (0,A.jsx)(Hg,{label:w(`更多操作`),triggerClassName:`ui-actbar-more`,items:o}):null]})]})}ir(),ti(rr);let Wg={info:`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18zM12 11v5M12 7.5v.5`,success:`M5 12.5l4.5 4.5L19 7`,warning:`M12 4l9 16H3zM12 10v4M12 17v.5`,danger:`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18zM12 8v5M12 16.5v.5`};function Gg({tone:e=`info`,title:t,children:n,actionLabel:r,onAction:i,onDismiss:a,className:o}){let s=Wg[e]?e:`info`,c=(s===`info`||s===`success`)&&a;return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-alert`,`ui-alert-`+s,o),role:s===`danger`?`alert`:`status`,children:[/* @__PURE__ */ (0,A.jsx)(Y,{d:Wg[s],className:`ui-alert-icon`}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-alert-content`,children:[t?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-alert-title`,children:t}):null,n?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-alert-body`,children:im(n)}):null]}),r?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-btn ui-btn-secondary ui-alert-action`,onClick:i,children:r}):null,c?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-alert-close`,"aria-label":w(`關閉提示`),onClick:a,children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`,size:16})}):null]})}let Kg={draft:{label:`草稿`,fill:``},doing:{label:`進行中`,fill:`M12 4a8 8 0 0 1 0 16z`},review:{label:`審核中`,fill:`M12 4a8 8 0 0 1 8 8h-8z`},done:{label:`完成`,fill:`M12 4a8 8 0 1 1 0 16a8 8 0 1 1 0-16z`},fail:{label:`失敗`,fill:`M12 4a8 8 0 1 1 0 16a8 8 0 1 1 0-16z`}};function qg({status:e,variant:t=`chip`,children:n,className:r}){let i=Kg[e]?e:`draft`;return/* @__PURE__ */ (0,A.jsxs)(`span`,{className:M(`ui-badge`,`ui-badge-`+i,t===`dot`&&`is-dot`,r),children:[/* @__PURE__ */ (0,A.jsxs)(`svg`,{className:`ui-badge-mark`,width:15,height:15,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsx)(`circle`,{cx:12,cy:12,r:8,fill:`none`,stroke:`currentColor`,strokeWidth:2.5}),Kg[i].fill?/* @__PURE__ */ (0,A.jsx)(`path`,{d:Kg[i].fill,fill:`currentColor`}):null]}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-badge-text`,children:n||w(Kg[i].label)})]})}let Jg={money:0,percent:1,size:1,count:0},Yg=e=>String(e).padStart(2,`0`);function Xg(){return S.locale}function Zg(e,t={}){if(!e)return``;let n=t.weekday!==!1;return t.long?new Intl.DateTimeFormat(S.locale,{year:`numeric`,month:`long`,day:`numeric`,weekday:n?`long`:void 0}).format(e):O()?m_(e)+(n?`(${new Intl.DateTimeFormat(`zh-TW`,{weekday:`narrow`}).format(e)})`:``):new Intl.DateTimeFormat(S.locale,{year:`numeric`,month:`2-digit`,day:`2-digit`,weekday:n?`short`:void 0}).format(e)}function Qg(e){return e?new Intl.DateTimeFormat(S.locale,O()?{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}:{hour:`numeric`,minute:`2-digit`}).format(e):``}function $g(e,t){if(!e)return``;let n=Zg(e,t);return O()&&n.endsWith(`)`)?n+Qg(e):`${n} ${Qg(e)}`}function e_(e,t=/* @__PURE__ */ new Date){if(!e)return``;let n=(t.getTime()-e.getTime())/1e3;if(n<0||n>=604800)return $g(e);let r=new Intl.RelativeTimeFormat(S.locale,{numeric:`auto`});return n<60?r.format(0,`second`):n<3600?r.format(-Math.floor(n/60),`minute`):n<86400?r.format(-Math.floor(n/3600),`hour`):r.format(-Math.floor(n/86400),`day`)}function t_(e){return new Intl.DateTimeFormat(S.locale,{year:`numeric`,month:`long`}).format(e)}function n_(){if(O())return 0;try{let e=new Intl.Locale(S.locale),t=e.getWeekInfo?e.getWeekInfo():e.weekInfo;if(t?.firstDay)return t.firstDay%7}catch{}return 0}function r_(){let e=n_(),t=new Intl.DateTimeFormat(S.locale,{weekday:`narrow`});return Array.from({length:7},(n,r)=>t.format(new Date(2026,10,1+(e+r)%7)))}function i_(e,t){let n=typeof t==`number`?t:t?Jg[t]:0;return new Intl.NumberFormat(S.locale,{minimumFractionDigits:n,maximumFractionDigits:n}).format(e)}function a_(e,t=1){return new Intl.NumberFormat(S.locale,{style:`percent`,minimumFractionDigits:t,maximumFractionDigits:t}).format(e/100)}function o_(e,t){let n=t??e;if(Math.abs(n)<1e4)return i_(e);if(/^zh/i.test(S.locale)){let r=Math.abs(n),[i,a,o]=Math.round(r/1e3)>=1e5?[`億`,1e8,2]:[`萬`,1e4,1],s=new Intl.NumberFormat(S.locale,{maximumFractionDigits:o}).format(r/a),c=e<0?`-`:``;if(t===void 0)return`${c}${s} ${i}`;let l=(s.split(`.`)[1]||``).length;return`${c}${new Intl.NumberFormat(S.locale,{minimumFractionDigits:l,maximumFractionDigits:l}).format(Math.abs(e)/a)} ${i}`}let r=new Intl.NumberFormat(S.locale,{notation:`compact`,maximumFractionDigits:1});if(t===void 0)return r.format(e);let i=r.formatToParts(n),a=``,o=``;for(let e of i)e.type===`integer`&&(a+=e.value),e.type===`fraction`&&(a+=`.`+e.value,o=e.value);let s=10**Math.round(Math.log10(Math.abs(n)/(parseFloat(a)||1))),c=new Intl.NumberFormat(S.locale,{minimumFractionDigits:o.length,maximumFractionDigits:o.length}).format(Math.abs(e)/s),l=!1,u=i.map(e=>e.type===`integer`||e.type===`group`||e.type===`decimal`||e.type===`fraction`?l?``:(l=!0,c):e.value).join(``);return(e<0&&n>=0?`-`:``)+u}function s_(e,t={}){let n=t.currency||S.currency,r=t.compact?o_(Math.abs(e),t.like===void 0?void 0:Math.abs(t.like)):i_(Math.abs(e),`money`);return O()&&n===`TWD`?`${e<0?`-`:``}NT$ ${r}`:t.compact?`${e<0?`-`:``}${r} ${n}`:new Intl.NumberFormat(S.locale,{style:`currency`,currency:n,currencyDisplay:n===`TWD`?`symbol`:`narrowSymbol`,minimumFractionDigits:0,maximumFractionDigits:n===`TWD`||n===`JPY`?0:2}).format(e)}function c_(e){return e==null||Number.isNaN(e)?``:Math.round(e/1024)<1024?i_(e===0?0:Math.max(1,Math.round(e/1024)))+` KB`:Math.round(e/1048576*10)<10240?i_(e/1048576,1)+` MB`:i_(e/1073741824,1)+` GB`}function l_(e){if(e==null||Number.isNaN(e)||e<0||!Number.isFinite(e))return`—`;let t=Math.round(e),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n?`${n}:${Yg(r)}:${Yg(i)}`:`${r}:${Yg(i)}`}function u_(e,t={}){let n=t.head??1,r=t.tail??2,i=String(e??``).split(`/`);return i.length>n+r?`${i.slice(0,n).join(`/`)}/…/${i.slice(-r).join(`/`)}`:String(e??``)}function d_(e,t,n){return w(n?`{n} / {total} {unit}`:`{n} / {total}`,{n:i_(e),total:i_(t),unit:n??``})}function f_(e,t,n){return w(n?`{total} {unit}中的 {n} {unit}`:`{total} 中的 {n}`,{n:i_(e),total:i_(t),unit:n??``})}let p_={locale:Xg,date:Zg,time:Qg,dateTime:$g,relative:e_,month:t_,weekdays:r_,firstDay:n_,number:i_,percent:a_,compact:o_,money:s_,fileSize:c_,duration:l_,path:u_,fraction:d_,fractionLabel:f_},m_=e=>e?`${e.getFullYear()}/${Yg(e.getMonth()+1)}/${Yg(e.getDate())}`:``;function h_(e){let t=/^(\d{4})\/(\d{1,2})\/(\d{1,2})$/.exec(e||``);if(!t)return null;let n=new Date(+t[1],t[2]-1,+t[3]);return n.getMonth()===t[2]-1?n:null}let g_=(e,t)=>!!e&&!!t&&e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),__=(e,t)=>new Date(e.getFullYear(),e.getMonth(),e.getDate()+t);function v_(e,t){let[n,r]=y.useState(+!!L());return y.useEffect(()=>{if(L())return;let e=null,n=0,i=a=>{e??=a;let o=Math.min(1,(a-e)/t);r(1-(1-o)**3),o<1&&(n=requestAnimationFrame(i))};return n=requestAnimationFrame(i),()=>cancelAnimationFrame(n)},[e,t]),n}let y_=e=>Math.min(3,(String(+(e/4).toPrecision(6)).split(`.`)[1]??``).length);function b_(e){let t=e=>e[0].toFixed(1)+`,`+e[1].toFixed(1);if(e.length<2)return e.length?`M`+t(e[0]):``;let n=`M`+t(e[0]);for(let r=0;r<e.length-1;r++){let i=e[r-1]||e[r],a=e[r],o=e[r+1],s=e[r+2]||o;n+=` C${t([a[0]+(o[0]-i[0])/6,a[1]+(o[1]-i[1])/6])} ${t([o[0]-(s[0]-a[0])/6,o[1]-(s[1]-a[1])/6])} ${t(o)}`}return n}let x_=[`var(--chart-1)`,`var(--chart-2)`,`var(--chart-3)`,`var(--chart-4)`],S_=e=>x_[e%x_.length],C_=[0,.25,.5,.75,1];function w_(e,t,n){let r=t.compact!==!1&&Math.abs(t.value)>=1e4;return t.format===`money`?p_.money(e,{compact:r,currency:t.currency,like:t.value}):t.format===`percent`?p_.number(e,n||1):r?p_.compact(e,t.value):p_.number(e,n)}function T_(e,t){y.useLayoutEffect(()=>{let t=e.current;if(!t)return;let n=()=>{t.style.fontSize=``;let e=parseFloat(getComputedStyle(t).fontSize)||31,n=t.querySelector(`.ui-kpi-sizer`),r=t.querySelector(`.ui-kpi-unit`),i=(n?n.scrollWidth:0)+(r?r.offsetWidth+4:0),a=t.clientWidth,o=i>a&&a>0?Math.max(20,Math.floor(e*a/i)):null;t.style.fontSize=o?o+`px`:``};n();let r=typeof ResizeObserver==`function`?new ResizeObserver(n):null;return r?.observe(t.parentNode||t),()=>r?.disconnect()},t)}function E_({title:e,rows:t,style:n}){return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-chart-tip`,style:n,children:[e?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-chart-tip-title`,children:e}):null,t.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-chart-tip-row`,children:[e.color?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-chart-swatch`,style:{background:e.color}}):null,/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-chart-tip-name`,children:e.name}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-chart-tip-val`,children:e.value})]},t))]})}function D_(e){let t=10**Math.floor(Math.log10(e||1)),n=Math.ceil(e/t);return(n<=2?2:n<=4?4:n<=5?5:n<=8?8:10)*t}function O_(e,t,n){if(e.altKey||e.metaKey||e.ctrlKey||!n)return null;let r=Math.max(0,t),i=e.key===`ArrowRight`?Math.min(n-1,r+1):e.key===`ArrowLeft`?Math.max(0,r-1):e.key===`Home`?0:e.key===`End`?n-1:null;return i!=null&&e.preventDefault(),i}function k_({data:e,label:t,unit:n,decimals:r,max:i,className:a}){let[o,s]=y.useState(-1),c=i||D_(Math.max(1,...e.map(e=>e.value))),l=n?` `+n:``,u=t=>{s(t),bi(e[t].label+w(`:`)+p_.number(e[t].value,r)+l)};return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-chart`,a),children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-bars`,role:`img`,"aria-label":t,"aria-description":w(`左右方向鍵查看每一項的數值`),tabIndex:e.length?0:void 0,onMouseLeave:()=>s(-1),onFocus:()=>o<0&&e.length&&u(0),onBlur:()=>s(-1),onKeyDown:t=>{let n=O_(t,o,e.length);n!=null&&u(n)},children:[C_.map((e,t)=>/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-bars-grid`,!t&&`is-axis`),style:{bottom:e*100+`%`},children:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-chart-tick`,children:p_.number(e*c,y_(c))})},`g`+t)),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-bars-row`,children:e.map((e,t)=>{let n=e.value/c*100+`%`;return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-bar-slot`,onMouseEnter:()=>s(t),children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-bar`,style:{height:n,animationDelay:t*40+`ms`,opacity:o>=0&&o!==t?.55:1}}),o===t?/* @__PURE__ */ (0,A.jsx)(E_,{style:{bottom:`calc(${n} + 8px)`,left:`50%`,transform:`translateX(-50%)`,whiteSpace:`nowrap`},rows:[{name:e.label,value:p_.number(e.value,r)+l}]}):null]},t)})})]}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-bars-labels`,children:e.map((e,t)=>/* @__PURE__ */ (0,A.jsx)(`span`,{children:ne(e.short||e.label)},t))})]})}Ne(),Fe(),ti(Me,Pe);function A_({focus:e,onPick:t,onHover:n,dayState:r}){let[i,a]=y.useState(()=>{let t=e||/* @__PURE__ */ new Date;return new Date(t.getFullYear(),t.getMonth(),1)}),o=/* @__PURE__ */ new Date,s=i.getFullYear(),c=i.getMonth(),[l,u]=y.useState(()=>e||o),d=l.getFullYear()===s&&l.getMonth()===c?l:new Date(s,c,Math.min(l.getDate(),new Date(s,c+1,0).getDate())),f=y.useRef(null),p=y.useRef(!1);y.useEffect(()=>{p.current&&(p.current=!1,f.current?.querySelector(`.ui-cal-day[tabindex="0"]`)?.focus())});let m=e=>{let t=e<d?-1:1;for(let n=0;n<31&&r?.(e)?.disabled;n++)e=__(e,t);u(e),(e.getMonth()!==c||e.getFullYear()!==s)&&a(new Date(e.getFullYear(),e.getMonth(),1)),p.current=!0,n?.(e)},h=e=>{if(W(e))return;let t=(d.getDay()-p_.firstDay()+7)%7,n=e=>{let t=new Date(d.getFullYear(),d.getMonth()+e+1,0).getDate();return new Date(d.getFullYear(),d.getMonth()+e,Math.min(d.getDate(),t))},r={ArrowLeft:()=>__(d,-1),ArrowRight:()=>__(d,1),ArrowUp:()=>__(d,-7),ArrowDown:()=>__(d,7),Home:()=>__(d,-t),End:()=>__(d,6-t),PageUp:()=>n(-1),PageDown:()=>n(1)};r[e.key]&&(e.preventDefault(),m(r[e.key]()))},g=(new Date(s,c,1).getDay()-p_.firstDay()+7)%7,_=new Date(s,c+1,0).getDate(),v=[...Array(g).fill(null),...Array.from({length:_},(e,t)=>new Date(s,c,t+1))];return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-cal`,children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-cal-head`,children:[/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-cal-nav`,"aria-label":w(`上個月`),onClick:()=>a(new Date(s,c-1,1)),children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-left`,size:16})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-cal-title`,"aria-live":`polite`,children:p_.month(i)}),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-cal-nav`,"aria-label":w(`下個月`),onClick:()=>a(new Date(s,c+1,1)),children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-right`,size:16})})]}),/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:f,className:`ui-cal-grid`,role:`group`,"aria-label":p_.month(i),onKeyDown:h,children:[p_.weekdays().map((e,t)=>/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-cal-wk`,"aria-hidden":`true`,children:e},`w`+t)),v.map((e,i)=>{if(!e)return/* @__PURE__ */ (0,A.jsx)(`span`,{},`e`+i);let a=r?.(e)??{},s=g_(e,o);return/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,disabled:a.disabled,className:M(`ui-cal-day`,a.selected&&`is-sel`,a.inRange&&`is-range`,a.start&&`is-start`,a.end&&`is-end`,s&&`is-today`),"aria-pressed":!!a.selected,"aria-label":p_.date(e,{weekday:!1,long:!0})+(s?w(`(今天)`):``),tabIndex:g_(e,d)?0:-1,onFocus:()=>!g_(e,d)&&u(e),onClick:()=>t?.(e),onMouseEnter:n?()=>n(e):void 0,children:e.getDate()},i)})]})]})}let j_=y.createContext(!1);function M_({as:e=`section`,title:t,actions:n,padding:r=!0,className:i,children:a,...o}){return G(y.useContext(j_),`Card`,`a Card inside a Card gives two shadows. Use one Card and separate its parts with headings or a divider.`),/* @__PURE__ */ (0,A.jsx)(j_.Provider,{value:!0,children:/* @__PURE__ */ (0,A.jsxs)(e,{...o,className:M(`ui-card`,!r&&`is-flush`,i),children:[t||n?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-card-head`,children:[t?/* @__PURE__ */ (0,A.jsx)(`h2`,{className:`ui-card-title`,children:t}):null,n?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-card-actions`,children:n}):null]}):null,a]})})}nr(),ti(tr);function N_({htmlFor:e,id:t,required:n,children:r}){return/* @__PURE__ */ (0,A.jsxs)(e?`label`:`span`,{htmlFor:e,id:t,className:`ui-field-label`,children:[r,n?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-req`,"aria-hidden":`true`,children:` *`}):null]})}function P_({v:e}){let[t,n]=y.useState(e),[r,i]=y.useState(!1);return t!==e&&(n(e),i(e===!0)),e===`mixed`?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-check-dash`}):e?/* @__PURE__ */ (0,A.jsx)(`svg`,{className:M(r&&`ui-draw`),width:14,height:14,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:3.5,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(`path`,{d:pi})}):null}function F_({inline:e}){return/* @__PURE__ */ (0,A.jsx)(Y,{name:`warning-circle`,className:M(`ui-field-icon`,e&&`is-inline`)})}function I_({id:e,error:t,hint:n,className:r}){return t?/* @__PURE__ */ (0,A.jsx)(`div`,{id:e,className:M(`ui-field-error`,r),role:`alert`,children:im(t)},t):n?/* @__PURE__ */ (0,A.jsx)(`div`,{id:e,className:M(`ui-field-hint`,r),children:im(n)}):null}function L_({checked:e,onChange:t,label:n,disabled:r,className:i,...a}){let o=e===`mixed`?`mixed`:!!e;return/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":o,"aria-label":a[`aria-label`],disabled:r,className:M(`ui-check`,o&&`is-on`,i),onClick:()=>t?.(o!==!0),children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-check-box`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(P_,{v:o})}),n?/* @__PURE__ */ (0,A.jsx)(`span`,{children:n}):null]})}let R_=/*#__PURE__*/ y.createContext(void 0);function z_(e){let t=y.useContext(R_);if(t===void 0&&!e)throw Error(Pi(50));return t}let B_={...Iu,instantType:e=>e.instantType,adaptiveOrigin:e=>e.adaptiveOrigin,closeDelay:e=>e.closeDelay};var V_=class extends Du{constructor(e,t,n){let r=new mu;super(H_(e,r,t,n),U_(r),B_)}setOpen=(e,t)=>{let{inlineRectCoordsRef:n}=this.context;cu(this,e,t,{onBeforeDispatch(){let r=t.event;e&&t.reason===`trigger-hover`&&t.trigger&&`clientX`in r&&`clientY`in r&&n.current?.element!==t.trigger&&Wl(n,t.trigger,r.clientX,r.clientY)}})}};function H_(e,t,n,r=!1){return{...Au(t,n,r),instantType:void 0,adaptiveOrigin:void 0,closeDelay:300,...e}}function U_(e){return{popupRef:/*#__PURE__*/ y.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e,inlineRectCoordsRef:{current:void 0}}}function W_(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,onOpenChangeComplete:i,actionsRef:a,handle:o,triggerId:s,defaultTriggerId:c=null,children:l}=e,u=nu((e,r)=>new V_({open:n,openProp:t,activeTriggerId:c,triggerIdProp:s},e,r));u.useControlledProp(`openProp`,t),u.useControlledProp(`triggerIdProp`,s),u.useContextCallback(`onOpenChange`,r),u.useContextCallback(`onOpenChangeComplete`,i);let d=u.useState(`open`),f=u.useState(`activeTriggerId`),p=u.useState(`mounted`),m=u.useState(`payload`);uu(u,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:h}=du(d,u,()=>{u.context.inlineRectCoordsRef.current=void 0});X(()=>{d&&(f??u.set(`payload`,void 0))},[u,f,d]),y.useImperativeHandle(a,()=>({unmount:h,close:()=>u.setOpen(!1,Q(ko))}),[h,u]);let g=d||p||o!=null;return/*#__PURE__*/ (0,A.jsxs)(R_.Provider,{value:u,children:[o&&/*#__PURE__*/ (0,A.jsx)(ru,{handle:o,store:u}),g&&/*#__PURE__*/ (0,A.jsx)(G_,{store:u}),typeof l==`function`?l({payload:m}):l]})}function G_({store:e}){let t=Fl(e.useState(`floatingRootContext`));return fu(e,{activeTriggerProps:t.reference,inactiveTriggerProps:t.trigger,popupProps:t.floating}),null}let K_=Di(function(e){return z_(!0)?/*#__PURE__*/ (0,A.jsx)(W_,{...e}):/*#__PURE__*/ (0,A.jsx)(yl,{children:/*#__PURE__*/ (0,A.jsx)(W_,{...e})})}),q_=/*#__PURE__*/ y.createContext(void 0);function J_(){let e=y.useContext(q_);if(e===void 0)throw Error(Pi(48));return e}let Y_=/*#__PURE__*/ y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return z_().useState(`mounted`)||n?/*#__PURE__*/ (0,A.jsx)(q_.Provider,{value:n,children:/*#__PURE__*/ (0,A.jsx)(Tf,{ref:t,...r})}):null}),X_=/*#__PURE__*/ y.createContext(void 0);function Z_(){let e=y.useContext(X_);if(e===void 0)throw Error(Pi(49));return e}let Q_=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`bottom`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=il,style:g,..._}=e,v=z_(),y=J_(),b=_l(),x=v.useState(`open`),S=v.useState(`mounted`),C=v.useState(`floatingRootContext`),w=v.useState(`instantType`),T=v.useState(`transitionStatus`),E=v.useState(`adaptiveOrigin`),D=v.context.inlineRectCoordsRef,O=Bf({anchor:i,floatingRootContext:C,positionMethod:a,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m,keepMounted:y,nodeId:b,collisionAvoidance:h,adaptiveOrigin:E,inline:Gl(D)}),k=O.update;X(()=>{x&&S&&k()},[x,S,k]);let j=Wf(e,{open:x,side:O.side,align:O.align,anchorHidden:O.anchorHidden,instant:w},{styles:O.positionerStyles,transitionStatus:T,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!S,inert:!x});return/*#__PURE__*/ (0,A.jsx)(X_.Provider,{value:O,children:/*#__PURE__*/ (0,A.jsx)(vl,{id:b,children:j})})}),$_=/*#__PURE__*/ y.forwardRef(function(e,t){let{className:n,render:r,style:i,...a}=e,o=z_(),{side:s,align:c}=Z_(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`closeDelay`);return Ql({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),Ku(p,{closeDelay:m}),Jc(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,o.useStateSetter(`popupElement`)],props:[eu,f,Uf(d),a],stateAttributesMapping:Xa})}),ev=/*#__PURE__*/ y.createContext(void 0);function tv(e){let t=y.useContext(ev);if(t===void 0&&!e)throw Error(Pi(47));return t}let nv={...Iu,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!Iu.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&Iu.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>Iu.isOpenedByTrigger(e,t)&&!e.focusManagerModal,modal:e=>e.modal,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin};var rv=class extends Du{constructor(e,t,n){let r=new mu;super(iv(e,r,t,n),av(r),nv)}setOpen=(e,t)=>{let n=t.reason===ho,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=su(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=ou(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.context.stickIfOpen=!0,this.context.stickIfOpenTimeout.start(500,()=>{this.context.stickIfOpen=!1}),b.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function iv(e,t,n,r=!1){let i={...Au(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function av(e){return{popupRef:/*#__PURE__*/ y.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:/*#__PURE__*/ y.createRef(),beforeTriggerFocusGuardRef:/*#__PURE__*/ y.createRef(),beforeContentFocusGuardRef:/*#__PURE__*/ y.createRef(),stickIfOpenTimeout:new Ri,stickIfOpen:!0,triggerElements:e}}let ov=Di(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=cv(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),pu(u,d),uu(u);let{forceUnmount:m}=du(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),y.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),y.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,Q(ko))}),[m,u]);let h=d||f||s!=null;return/*#__PURE__*/ (0,A.jsxs)(ev.Provider,{value:u,children:[s&&/*#__PURE__*/ (0,A.jsx)(ru,{handle:s,store:u}),h&&/*#__PURE__*/ (0,A.jsx)(lv,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function sv(e){return tv(!0)?/*#__PURE__*/ (0,A.jsx)(ov,{props:e}):/*#__PURE__*/ (0,A.jsx)(yl,{children:/*#__PURE__*/ (0,A.jsx)(ov,{props:e})})}function cv(e,t){let n=nu((e,n)=>new rv(t,e,n));return y.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function lv({store:e,modal:t}){let n=Fl(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return fu(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}let uv=Oi(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=tv(!0),h=Lu(s)??m;if(!h)throw Error(Pi(74));let g=_f(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),b=h.useState(`isOpenedByTrigger`,g),x=h.useState(`triggerPopupId`,g),S=y.useRef(null),{registerTrigger:C,isMountedByThisTrigger:w}=lu(g,S,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),T=h.useState(`isPressOpenedByTrigger`,g),E=h.useState(`isTouchPressOpen`,l),D=h.useState(`hasTriggerFocusGuards`,g),O=Ju(v,{enabled:!a&&l&&!E,mouseOnly:!0,move:!1,handleClose:cd(),restMs:u,delay:{close:d},triggerElementRef:S,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),k=kl(v,{stickIfOpen:$(()=>h.context.stickIfOpen)}),j=Kp(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),M=h.useState(`triggerProps`,w),{getButtonProps:N,buttonRef:P}=pp({disabled:a,native:o}),F={open(e){return T?Ja.open(e):qa.open(e)}},{handlePreFocusGuardFocus:I,handleFocusTargetFocus:L}=bg(h,S),R=Jc(`button`,e,{state:{disabled:a,open:b},ref:[P,t,C,S],props:[k.reference,O,M,j,{[nl]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":b,"aria-controls":x},p,N],stateAttributesMapping:F}),z=/*#__PURE__*/ (0,A.jsx)(y.Fragment,{children:R},g);return D?/*#__PURE__*/ (0,A.jsxs)(y.Fragment,{children:[/*#__PURE__*/ (0,A.jsx)(ts,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:I}),z,/*#__PURE__*/ (0,A.jsx)(ts,{ref:h.context.triggerFocusTargetRef,onFocus:L})]}):z}),dv=/*#__PURE__*/ y.createContext(void 0);function fv(){let e=y.useContext(dv);if(e===void 0)throw Error(Pi(45));return e}let pv=/*#__PURE__*/ y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return tv().useState(`mounted`)||n?/*#__PURE__*/ (0,A.jsx)(dv.Provider,{value:n,children:/*#__PURE__*/ (0,A.jsx)(ul,{ref:t,...r})}):null}),mv=/*#__PURE__*/ y.createContext(void 0);function hv(){let e=y.useContext(mv);if(!e)throw Error(Pi(46));return e}let gv=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=il,..._}=e,v=tv(),y=fv(),b=_l(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),j=v.useState(`transitionStatus`),M=Bf({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:v.useState(`adaptiveOrigin`)});Uh({store:v,domReference:x.useState(`domReferenceElement`),positionerElement:O,open:C});let N=E===!0&&w!==`trigger-hover`;Wh(C&&N,D===`touch`,O,T);let P=v.useStateSetter(`positionerElement`),F=Wf(e,{open:C,side:M.side,align:M.align,anchorHidden:M.anchorHidden,instant:k},{styles:M.positionerStyles,transitionStatus:j,props:_,refs:[t,P],hidden:!S,inert:!C});return/*#__PURE__*/ (0,A.jsxs)(mv.Provider,{value:M,children:[S&&N&&/*#__PURE__*/ (0,A.jsx)(Sp,{inert:Jf(!C),cutout:T}),/*#__PURE__*/ (0,A.jsx)(vl,{id:b,children:F})]})}),_v=/*#__PURE__*/ y.createContext(void 0);function vv(){let[e,t]=y.useState(0),n=$(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:y.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}function yv(){let e=y.useContext(_v);X(()=>e?.register(),[e])}let bv=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=tv(),l=hv(),u=Ch(!0)!=null,{context:d,hasClosePart:f}=vv(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);Ql({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),Ku(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?tu(c.context.popupRef):a,j=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,j);let M=c.useStateSetter(`popupElement`),N=Jc(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,M],props:[_,{id:T,role:`dialog`,...eu,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&yp.has(e.key)&&e.stopPropagation()}},Uf(g),s],stateAttributesMapping:Xa});return/*#__PURE__*/ (0,A.jsx)(Ol,{context:w,openInteractionType:m,modal:j,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:pa(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:/*#__PURE__*/ (0,A.jsx)(_v.Provider,{value:d,children:N})})}),xv=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=tv().useState(`open`),{arrowRef:s,side:c,align:l,arrowUncentered:u,arrowStyles:d}=hv();return Jc(`div`,e,{state:{open:o,side:c,align:l,uncentered:u},ref:[t,s],props:[{style:d,"aria-hidden":!0},a],stateAttributesMapping:Ya})}),Sv=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=tv(),s=_f(a.id);return o.useSyncedValueWithCleanup(`titleElementId`,s),Jc(`h2`,e,{ref:t,props:[{id:s},a]})}),Cv=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,{buttonRef:c,getButtonProps:l}=pp({disabled:a,focusableWhenDisabled:!1,native:o}),u=tv();return yv(),Jc(`button`,e,{ref:[t,c],props:[{onClick(e){u.setOpen(!1,Q(vo,e.nativeEvent))}},s,l]})});function wv({open:e,onOpenChange:t,trigger:n,side:r=`bottom`,align:i=`start`,sideOffset:a=6,className:o,openOnHover:s,anchor:c,boundary:l,delay:u=0,id:d,focusOnOpen:f=!0,children:p,...m}){let h=l?.current??void 0;return/* @__PURE__ */ (0,A.jsxs)(sv,{open:e,onOpenChange:t,children:[/* @__PURE__ */ (0,A.jsx)(uv,{render:n,openOnHover:s,delay:u,closeDelay:150}),/* @__PURE__ */ (0,A.jsx)(pv,{children:/* @__PURE__ */ (0,A.jsx)(gv,{className:`ui-float`,side:r,align:i,sideOffset:a,anchor:c,collisionBoundary:h,collisionPadding:h?0:void 0,collisionAvoidance:h?{side:`flip`,align:`shift`}:void 0,children:/* @__PURE__ */ (0,A.jsx)(bv,{id:d,className:o,"aria-label":m[`aria-label`],initialFocus:f?void 0:!1,children:p})})})]})}En(),ir(),ti(Tn,rr);function Tv({children:e,title:t,text:n,content:r,code:i,action:a,refHref:o,onRef:s,isRef:c,variant:l=`icon`,openOnFocus:u=!0,tabIndex:d,className:f}){let[p,m]=y.useState(!1),h=ee(),g=l===`inline`,_=y.useId(),v=y.useRef(null),[b,x]=y.useState(!1);y.useLayoutEffect(()=>{let e=v.current?.parentNode,t=!!e&&Array.from(e.childNodes).some(e=>e.nodeType===3&&!!e.textContent?.trim());x(t)},[e]);let S=y.useRef(null),C=e=>{if(e){let e=v.current?.closest(`.ui-card, .ui-split-a, .ui-split-b, .ui-shell-main, main`)??null;S.current=e&&e.getBoundingClientRect().width>=240?e:null}m(e)},T=t||(typeof e==`string`?e:``),E=e=>{u&&!h&&e.currentTarget.matches(`:focus-visible`)&&C(!0)},D=e=>{let t=e.relatedTarget;t&&(v.current?.contains(t)||document.getElementById(_)?.contains(t))||h||m(!1)},O=g?/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,ref:v,className:M(`ui-term`,`is-word`,p&&`is-open`,f),tabIndex:d,"aria-describedby":p&&!h?_:void 0,onFocus:E,onBlur:D,children:[e,/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:w(`,有說明`)})]}):/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,ref:v,className:M(`ui-term`,b&&`is-inline`,p&&`is-open`,f),children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:w(`說明`)+` `}),e,/* @__PURE__ */ (0,A.jsx)(Y,{name:`question`,size:14,className:`ui-term-q`})]}),k=(e,t)=>/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-term-head`,children:[/* @__PURE__ */ (0,A.jsx)(e,{className:`ui-term-title`,children:T}),/* @__PURE__ */ (0,A.jsx)(t,{className:`ui-dialog-close ui-term-close`,"aria-label":w(`關閉說明`),children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`})})]}),n?/* @__PURE__ */ (0,A.jsx)(rm,{as:`div`,className:`ui-term-body`,text:n,refHref:o,onRef:s,isRef:c}):null,r?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-term-body`,children:r}):null,i?/* @__PURE__ */ (0,A.jsx)(`pre`,{className:`ui-term-code`,children:i}):null,a?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn ui-term-action`,onClick:()=>{m(!1),a.onClick?.()},children:a.label}):null]});return h?/* @__PURE__ */ (0,A.jsxs)(Vp,{open:p,onOpenChange:m,children:[/* @__PURE__ */ (0,A.jsx)(Jp,{render:O}),/* @__PURE__ */ (0,A.jsxs)(Cp,{children:[/* @__PURE__ */ (0,A.jsx)(cp,{className:`ui-term-backdrop`}),/* @__PURE__ */ (0,A.jsx)(xp,{className:`ui-term-sheet`,children:k(Up,gp)})]})]}):/* @__PURE__ */ (0,A.jsx)(wv,{open:p,onOpenChange:C,sideOffset:8,className:`ui-term-pop`,trigger:O,boundary:S,...g?{openOnHover:!0,delay:500,id:_,focusOnOpen:!1}:{},children:g?/* @__PURE__ */ (0,A.jsx)(`div`,{onBlur:D,children:k(Sv,Cv)}):k(Sv,Cv)})}let Ev=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),Dv=/^[\p{Script=Latin}\p{N}_]$/u;function Ov(e){let t=(e??[]).filter(e=>e.term);if(!t.length)return null;let n=[...t].sort((e,t)=>t.term.length-e.term.length).map(e=>{let t=[...e.term],n=Dv.test(t[0])?`(?<![\\p{Script=Latin}\\p{N}_])`:``,r=Dv.test(t[t.length-1])?`(?![\\p{Script=Latin}\\p{N}_])`:``;return n+Ev(e.term)+r});return new RegExp(n.join(`|`),`gu`)}function kv(e,t,n,r,i){let a=[];for(let o of e.matchAll(n)){let e=t.findIndex(e=>e.term===o[0]);if(!(e<0)){if(r===`first`){if(i.has(o[0]))continue;i.add(o[0])}a.push({from:o.index,to:o.index+o[0].length,i:e})}}return a}function Av(e,t,n,r){return/* @__PURE__ */ (0,A.jsx)(Tv,{variant:`inline`,title:e.title,text:e.text,action:e.action,...r,children:n??e.term},t)}function jv(e,t,n,r,i=e=>e,a){let o=[],s=0;for(let c of t)c.from>s&&o.push(/* @__PURE__ */ (0,A.jsx)(y.Fragment,{children:i(e.slice(s,c.from))},r())),o.push(Av(n[c.i],r(),e.slice(c.from,c.to),a)),s=c.to;return s<e.length&&o.push(/* @__PURE__ */ (0,A.jsx)(y.Fragment,{children:i(e.slice(s))},r())),o}let Mv={c:new Set(`auto break case char const continue default do double else enum extern float for goto if inline int long register restrict return short signed sizeof static struct switch typedef union unsigned void volatile while bool true false NULL nullptr class namespace template typename public private protected virtual new delete`.split(` `)),js:new Set(`async await break case catch class const continue default delete do else export extends false finally for from function if import in instanceof let new null of return static super switch this throw true try typeof undefined var void while yield interface type enum implements`.split(` `)),py:new Set(`and as assert async await break class continue def del elif else except False finally for from global if import in is lambda None nonlocal not or pass raise return True try while with yield`.split(` `)),sh:new Set(`if then else elif fi for while do done case esac in function return export local set unset echo exit`.split(` `))},Nv={c:`c`,h:`c`,cc:`c`,cpp:`c`,hpp:`c`,cu:`c`,js:`js`,jsx:`js`,ts:`js`,tsx:`js`,mjs:`js`,py:`py`,sh:`sh`,bash:`sh`};function Pv(e){let t=/\.([A-Za-z0-9]+)$/.exec(e||``);return t&&Nv[t[1].toLowerCase()]||`plain`}let Fv={c:`C 語言`,js:`JavaScript`,py:`Python`,sh:`Shell`},Iv=(e,t)=>{let n=Mv[t];if(!n)return e.map(e=>[[``,e]]);let r=t===`py`||t===`sh`,i=r?/(#.*$)|("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')|([A-Za-z_]\w*)|(\b\d[\w.]*)/g:/(\/\/.*$|\/\*.*?(?:\*\/|$))|("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`)|([A-Za-z_]\w*)|(\b\d[\w.]*)/g,a=!1;return e.map(e=>{let t=[],o=0;if(a){let n=e.indexOf(`*/`);if(n<0)return[[`is-comment`,e]];t.push([`is-comment`,e.slice(0,n+2)]),o=n+2,a=!1}i.lastIndex=o;let s;for(;s=i.exec(e);){s.index>o&&t.push([``,e.slice(o,s.index)]);let c=s[1]?`is-comment`:s[2]?`is-string`:s[3]?n.has(s[3])?`is-keyword`:/^[A-Z][A-Z0-9_]+$/.test(s[3])?`is-constant`:``:`is-constant`;s[1]&&!r&&s[1].startsWith(`/*`)&&!s[1].endsWith(`*/`)&&(a=!0),t.push([c,s[0]]),o=s.index+s[0].length,s[0].length||i.lastIndex++}return o<e.length&&t.push([``,e.slice(o)]),t.length?t:[[``,``]]})};rt(),Ir(),ti(nt,Fr);function Lv(e){let t=/^[ \t]*/.exec(e)?.[0]??``;if(!t||t.length===e.length)return``;let n=t.split(` `).length-1,r=t.length-n;return w(`,`)+(n&&r?w(`縮排 {a} 個 tab、{b} 格`,{a:n,b:r}):n?w(`縮排 {n} 個 tab`,{n}):w(`縮排 {n} 格`,{n:r}))}let Rv=/(->|::|==|!=|<=|>=|&&|\|\||\+\+|--|<<|>>|=>|\+=|-=|\*=|\/=)/,zv=/([,.([{;])/,Bv=/(?<![\w./-])((?:\.{1,2}\/)?(?:[\w.-]+\/)+[\w.-]+\.[A-Za-z0-9]+(?::\d+(?:-\d+)?)?|[\w.-]+\.[A-Za-z0-9]+:\d+(?:-\d+)?)(?![\w/])/g;function Vv(e,t,n,r){let i=[],a=0;for(let o of e.matchAll(Bv)){let s=o[1],c=t&&t(s)||void 0;if(t?!c:!n)continue;o.index>a&&i.push(Hv(e.slice(a,o.index)));let l=n?e=>{c&&(e.metaKey||e.ctrlKey||e.shiftKey||e.button===1)||(e.preventDefault(),n(s,e))}:void 0;i.push(c?/* @__PURE__ */ (0,A.jsx)(`a`,{className:`ui-cv-ref`,href:c,onClick:l,tabIndex:r,children:s},o.index):/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-cv-ref`,onClick:l,tabIndex:r,children:s},o.index)),a=o.index+s.length}return i.length?(a<e.length&&i.push(Hv(e.slice(a))),i):Hv(e)}function Hv(e){if(!Rv.test(e)&&!zv.test(e))return e;let t=[];return e.split(Rv).forEach((e,n)=>{e&&(n%2?t.push(/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-cv-op`,children:e},n),/* @__PURE__ */ (0,A.jsx)(`wbr`,{},n+`w`)):e.split(zv).forEach((e,r)=>{e&&(t.push(e),r%2&&t.push(/* @__PURE__ */ (0,A.jsx)(`wbr`,{},n+`.`+r)))}))}),t}let Uv=/[\p{L}\p{N}_$]/u;function Wv(e,t){let n=0;for(let r=1;r<t;r++){if(n>=e.length)return-1;n+=(e.codePointAt(n)??0)>65535?2:1}return n}function Gv(e,t){for(let n=e.indexOf(t);n>=0;n=e.indexOf(t,n+1)){let r=e[n-1]??``,i=e[n+t.length]??``;if(!Uv.test(r)&&r!==`.`&&!Uv.test(i))return n}return-1}function Kv(e,t,n){let r=/* @__PURE__ */ new Map;n?.forEach((n,i)=>{let a=e[n.line-t];if(a==null){G(!0,`CodeView`,`第 ${n.line} 行不在程式碼裡,連結「${n.text}」沒有加上。line 和 target 一樣從 start(${t})算起。`);return}let o=-1;if(n.col!=null){let e=Wv(a,n.col);e>=0&&a.startsWith(n.text,e)?o=e:G(!0,`CodeView`,`第 ${n.line} 行第 ${n.col} 欄不是「${n.text}」,連結沒有加上。col 從 1 開始、以字元計;位元組或 UTF-16 位置要先換算。`)}else o=Gv(a,n.text),G(o<0,`CodeView`,`第 ${n.line} 行找不到完整的「${n.text}」,連結沒有加上。text 要和程式碼一字不差(整個帶點的名稱),或給 col。`);if(o<0)return;let s={from:o,to:o+n.text.length,i},c=r.get(n.line)??[];c.some(e=>e.from<s.to&&s.from<e.to)?G(!0,`CodeView`,`第 ${n.line} 行的「${n.text}」和另一個連結重疊,沒有加上。同一行出現兩次的名稱,第二個要給 col。`):(c.push(s),r.set(n.line,c))});for(let e of r.values())e.sort((e,t)=>e.from-t.from);return r}function qv(e){let t=typeof window>`u`?null:window.getSelection();if(!e||!t||t.isCollapsed||!t.rangeCount)return!1;let n=t.getRangeAt(0);return e.contains(n.startContainer)||e.contains(n.endContainer)}function Jv(e){let t=window.getSelection();if(!t||t.isCollapsed||!t.rangeCount)return null;let n=t.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return null;let r=n.cloneContents();r.querySelectorAll(`.ui-cv-num, .ui-visually-hidden`).forEach(e=>e.remove());let i=[...r.querySelectorAll(`[role="listitem"]`)];return i.length?i.map(e=>e.textContent??``).join(`
80
+ `):r.textContent??``}function Yv(e){for(let t=e;t&&t!==document.body&&t!==document.documentElement;t=t.parentElement){let e=getComputedStyle(t).overflowY;if((e===`auto`||e===`scroll`||e===`overlay`)&&t.scrollHeight>t.clientHeight)return t}return null}function Xv(e,t,n){let r=Yv(n),i=r?(()=>{let e=r.getBoundingClientRect().top+r.clientTop;return{top:e,bottom:e+r.clientHeight}})():{top:0,bottom:window.innerHeight},a=e.getBoundingClientRect().top,o=t.getBoundingClientRect().bottom,s=0;o-a>i.bottom-i.top||a<i.top?s=a-i.top:o>i.bottom&&(s=o-i.bottom),s=Math.round(s),s&&(r?r.scrollTop+=s:window.scrollBy(0,s))}function Zv(e,t,n,r,i){let a=/* @__PURE__ */ new Map,o=Ov(r);if(!o||!r)return a;let s=/* @__PURE__ */ new Set;return e.forEach((e,c)=>{let l=t+c,u=n.get(l)??[],d=0;for(let[t,n]of e){if(t===`is-comment`||t===`is-string`){let e=[...n.matchAll(Bv)].map(e=>({from:d+e.index,to:d+e.index+e[0].length})),t=(t,n)=>![...u,...e].some(e=>e.from<n&&t<e.to),c=kv(n,r,o,`all`,/* @__PURE__ */ new Set).map(e=>({...e,from:e.from+d,to:e.to+d})).filter(e=>t(e.from,e.to)).filter(e=>{if(i===`all`)return!0;let t=r[e.i].term;return!s.has(t)&&(s.add(t),!0)});c.length&&a.set(l,[...a.get(l)??[],...c])}d+=n.length}}),a}function Qv(e){return/* @__PURE__ */ (0,A.jsx)(wv,{open:e.open,onOpenChange:e.onOpenChange,trigger:e.trigger,side:`bottom`,align:`end`,className:`ui-popover ui-cv-keys`,"aria-label":w(`鍵盤操作`),children:/* @__PURE__ */ (0,A.jsxs)(`dl`,{className:`ui-cv-keylist`,children:[e.keys.map(e=>/* @__PURE__ */ (0,A.jsxs)(`div`,{children:[/* @__PURE__ */ (0,A.jsx)(`dt`,{children:/* @__PURE__ */ (0,A.jsx)(`kbd`,{children:e.label})}),/* @__PURE__ */ (0,A.jsx)(`dd`,{children:e.what})]},e.k)),/* @__PURE__ */ (0,A.jsxs)(`div`,{children:[/* @__PURE__ */ (0,A.jsx)(`dt`,{children:/* @__PURE__ */ (0,A.jsx)(`kbd`,{children:`?`})}),/* @__PURE__ */ (0,A.jsx)(`dd`,{children:w(`顯示或關閉這份說明`)})]})]})})}function $v({code:e,start:t=1,target:n,context:r=2,file:i,fileHref:a,onFile:o,title:s,language:c,languageLabel:l,highlight:u=!0,tokenizer:d=Iv,refHref:f,onRef:p,links:m,onLink:h,preview:g,terms:_,termsMark:v=`first`,maxHeight:b,sections:x,copy:S,header:C=!0,lineNumbers:T=!0,onCopy:E,onCopyError:D,onLine:O,peek:k,className:j,ref:N}){let P=y.useMemo(()=>String(e||``).replace(/\n$/,``).split(`
81
+ `),[e]),I=c||Pv(i),L=y.useMemo(()=>u?d(P,I):P.map(e=>[[``,e]]),[P,I,u,d]),R=y.useMemo(()=>Kv(P,t,m),[P,t,m]),z=y.useMemo(()=>Zv(L,t,R,_,v),[L,t,R,_,v]),B=R.size>0||z.size>0,[V,H]=y.useState(!1),U=y.useRef(!1);y.useEffect(()=>{if(!B)return;let e=e=>{(e.key===`Control`||e.key===`Meta`)&&H(e.type===`keydown`&&U.current)},t=()=>H(!1);return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,e),window.addEventListener(`blur`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,e),window.removeEventListener(`blur`,t)}},[B]);let[ne,W]=y.useState(null),re=y.useId(),ie=y.useRef(void 0),G=y.useRef(void 0);y.useEffect(()=>()=>{clearTimeout(ie.current),clearTimeout(G.current)},[]);let K=e=>{g&&(clearTimeout(G.current),clearTimeout(ie.current),ne?.el!==e&&(ie.current=setTimeout(()=>W({i:Number(e.dataset.link),el:e}),500)))},q=()=>{clearTimeout(ie.current),clearTimeout(G.current),G.current=setTimeout(()=>W(null),200)},ae=()=>clearTimeout(G.current),oe=e=>e instanceof Element?e.closest(`.ui-cv-name`):null,se=(e,t)=>{let n=m?.[Number(e.dataset.link)];n&&(clearTimeout(ie.current),W(null),h?h(n,t):n.href&&window.location.assign(n.href))},ce=e=>{let t=oe(e.target);if(!t)return;let n=m?.[Number(t.dataset.link)]?.href;if(e.shiftKey&&n)return;e.preventDefault();let r=e.nativeEvent.pointerType;(e.detail===0||r===`touch`||r===`pen`||e.ctrlKey||e.metaKey)&&se(t,e)},[le,J]=n==null?[null,null]:Array.isArray(n)?n:[n,n],ue=ee(),[de,fe]=y.useState(!1),[pe,me]=y.useState({code:e,ta:le,tb:J});(pe.code!==e||pe.ta!==le||pe.tb!==J)&&(me({code:e,ta:le,tb:J}),fe(!1));let he=le!=null&&J!=null&&P.length>J-le+1+r*2,ge=ue&&he&&!de,_e=ge?Math.max(0,le-t-r):0,ve=ge?Math.min(P.length,J-t+r+1):P.length,ye=y.useRef(null);y.useImperativeHandle(N,()=>({focusTarget:()=>{qv(ye.current)||ye.current?.querySelector(`.is-target`)?.focus()}})),y.useEffect(()=>{let e=ye.current,t=e?.querySelector(`.is-target`);e&&t&&e.scrollHeight>e.clientHeight&&!qv(e)&&(e.scrollTop+=t.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientHeight/2+t.offsetHeight/2)},[le,e]);let[be,xe]=k==null?[NaN,NaN]:typeof k==`number`?[k,k]:[Math.min(k.from,k.to),Math.max(k.from,k.to)];y.useEffect(()=>{if(Number.isNaN(be))return;let e=ye.current;if(!e)return;let t=[...e.querySelectorAll(`[data-n]`)].filter(e=>{let t=Number(e.dataset.n);return t>=be&&t<=xe});t.length&&Xv(t[0],t[t.length-1],e)},[be,xe]);let Se=String(t+P.length-1).length,Ce=(e,t,n)=>!n&&(f||p)&&(e===`is-comment`||e===`is-string`)?Vv(t,f,p,B?-1:void 0):Hv(t),we=(e,t,n,r,i=0,a)=>{let o=!r&&_&&a?a.filter(e=>e.from>=i&&e.to<=i+t.length):[],s=0,c=o.length&&_?jv(t,o.map(e=>({...e,from:e.from-i,to:e.to-i})),_,()=>n+`t`+s++,t=>Ce(e,t,!1),{className:`ui-cv-term`,tabIndex:-1,openOnFocus:!1}):Ce(e,t,r);return e?/* @__PURE__ */ (0,A.jsx)(`span`,{className:e,children:c},n):/* @__PURE__ */ (0,A.jsx)(y.Fragment,{children:c},n)},Te=(e,t)=>{let n=m?.[e.i];return n?/* @__PURE__ */ (0,A.jsx)(`a`,{className:`ui-cv-name`,href:n.href,role:n.href?void 0:`link`,tabIndex:-1,draggable:!1,"data-link":e.i,"aria-label":n.label,"aria-describedby":ne?.i===e.i?re:void 0,title:g?void 0:n.label,children:t},`n`+e.i):null},Ee=(e,t,n)=>{if(!t){let t=0;return e.map(([e,r],i)=>{let a=we(e,r,String(i),!1,t,n);return t+=r.length,a})}let r=[],i=[],a=null,o=()=>{a&&r.push(Te(a,i)),a=null,i=[]},s=0,c=0;return e.forEach(([e,l],u)=>{let d=0;for(;d<l.length;){let f=s+d;for(;c<t.length&&t[c].to<=f;)c++;let p=t[c],m=p&&p.from<=f?p:null,h=Math.min(s+l.length,m?m.to:p?p.from:1/0),g=u+`.`+d;m?(a!==m&&(o(),a=m),i.push(we(e,l.slice(d,h-s),g,!0))):(o(),r.push(we(e,l.slice(d,h-s),g,!1,f,n))),d=h-s}s+=l.length}),o(),r},De=[];for(let e=_e;e<ve;e++){let n=t+e,r=le!=null&&J!=null&&n>=le&&n<=J;De.push(/* @__PURE__ */ (0,A.jsxs)(`div`,{role:`listitem`,className:M(`ui-cv-line`,r&&`is-target`,n>=be&&n<=xe&&`is-peek`),"data-n":n,"aria-current":r&&n===le?`location`:void 0,tabIndex:r&&n===le?-1:void 0,children:[T?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-cv-num`,style:{width:`calc(${Se}ch + 28px)`},"aria-hidden":`true`,children:n}):null,/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-cv-text`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden ui-cv-sr`,children:w(`第 {n} 行`,{n})+Lv(P[e])+w(`:`)}),Ee(L[e],R.get(n),z.get(n))]})]},e))}let Oe=[...B?[{k:`ArrowUp ArrowDown`,label:`↑↓`,what:w(`上一行/下一行`)},{k:`ArrowLeft ArrowRight`,label:`←→`,what:w(z.size?R.size?`上一個/下一個連結或名詞`:`上一個/下一個名詞`:`上一個/下一個連結`)},{k:`Enter`,label:`Enter`,what:w(`開啟`)},{k:`Escape`,label:`Esc`,what:w(`回到這一行`)}]:[],{k:`Home`,label:`Home`,what:w(`第一行`)},{k:`End`,label:`End`,what:w(`最後一行`)},{k:`PageUp`,label:`PgUp`,what:w(`上 20 行`)},{k:`PageDown`,label:`PgDn`,what:w(`下 20 行`)},...x?.length?[{k:`[`,label:`[`,what:w(`上一段`)},{k:`]`,label:`]`,what:w(`下一段`)}]:[]],ke=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;if(e.key===`?`){e.preventDefault(),Ie.current=!0,Fe(e=>!e);return}let t=e.currentTarget,n=[...t.querySelectorAll(`[role="listitem"]`)];if(!n.length)return;let r=e=>Number(e.dataset.n),i=document.activeElement instanceof HTMLElement?document.activeElement:null,a=i&&i!==t?i.closest(`[role="listitem"]`):null,o=a?n.indexOf(a):-1,s=o<0?-1:o,c=e=>{e&&(e.tabIndex=-1,e.focus(),O?.(r(e),`key`))};if(O&&!B&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){e.preventDefault(),c(s<0?n.find(e=>e.classList.contains(`is-target`))??n[0]:n[Math.max(0,Math.min(n.length-1,s+(e.key===`ArrowDown`?1:-1)))]);return}if(B){let o=[...t.querySelectorAll(`.ui-cv-name, .ui-cv-ref, .ui-cv-term`)],l=i?o.indexOf(i):-1;if(e.key===`Escape`){if(i?.classList.contains(`ui-cv-term`)&&i.getAttribute(`aria-expanded`)===`true`)return;if(ne)W(null);else if(l>=0)c(a??void 0);else if(a)t.focus();else return;e.preventDefault();return}if(e.key===`Enter`&&i&&l>=0&&i.classList.contains(`ui-cv-name`)&&!i.hasAttribute(`href`)){e.preventDefault(),se(i,e);return}if(e.key===`ArrowUp`||e.key===`ArrowDown`){e.preventDefault(),c(s<0?n.find(e=>e.classList.contains(`is-target`))??n[0]:n[Math.max(0,Math.min(n.length-1,s+(e.key===`ArrowDown`?1:-1)))]);return}if(e.key===`ArrowLeft`||e.key===`ArrowRight`){e.preventDefault();let t=e.key===`ArrowRight`,i;if(l>=0)i=o[l+(t?1:-1)];else{let e=a?r(a):le??r(n[0]),s=e=>Number(e.closest(`[role="listitem"]`)?.dataset.n);i=t?o.find(t=>s(t)>=e):o.filter(t=>s(t)<=e).pop()}i?.focus();return}}let l=-1,u=``;if(e.key===`Home`)l=0;else if(e.key===`End`)l=n.length-1;else if(e.key===`PageDown`)l=Math.min(n.length-1,Math.max(0,s)+20);else if(e.key===`PageUp`)l=Math.max(0,s-20);else if((e.key===`[`||e.key===`]`)&&x?.length){let t=s<0?e.key===`]`?-1/0:1/0:r(n[s]),i=[...x].sort((e,t)=>e.line-t.line),a=e.key===`]`?i.find(e=>e.line>t):[...i].reverse().find(e=>e.line<t);a&&(l=n.findIndex(e=>r(e)>=a.line),u=a.label)}else return;e.preventDefault();let d=n[l];d&&(d.tabIndex=-1,d.focus(),O?.(r(d),`key`),u&&bi(w(`{name},第 {n} 行`,{name:u,n:r(d)})))},Ae=e=>{if(!O)return;let t=e.target instanceof Element?e.target:null;if(!t)return;let n=e.nativeEvent.pointerType;if(t.closest(`.ui-cv-name`)&&(e.detail===0||n===`touch`||n===`pen`||e.ctrlKey||e.metaKey)||t.closest(`a:not(.ui-cv-name), button:not(.ui-cv-name)`)||qv(e.currentTarget))return;let r=t.closest(`[role="listitem"]`);r&&O(Number(r.dataset.n),`click`)},je=e=>{let t=Jv(e.currentTarget);t!=null&&(e.preventDefault(),e.clipboardData.setData(`text/plain`,t))},[Me,Ne]=y.useState(!1),[Pe,Fe]=y.useState(!1),Ie=y.useRef(!1),Le=y.useRef(void 0);y.useEffect(()=>()=>clearTimeout(Le.current),[]);let Re=()=>{te(e).then(()=>{Ne(!0),bi(w(`已複製`)),clearTimeout(Le.current),Le.current=setTimeout(()=>Ne(!1),2e3),E?.(e)},()=>D?.())},ze=l!==!1&&I!==`plain`?/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-cv-lang`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:w(`程式語言`)+w(`:`)}),w(l||Fv[I]||I)]}):null,Be=S?/* @__PURE__ */ (0,A.jsx)(np,{className:M(`ui-cv-copy`,Me&&`is-copied`),variant:C===`float`?`quiet`:void 0,label:w(Me?`已複製`:`複製程式碼`),icon:Me?pi:`copy`,onClick:Re}):null,Ve=e=>{Fe(e),!e&&Ie.current&&(Ie.current=!1,requestAnimationFrame(()=>ye.current?.focus()))},He=e=>/* @__PURE__ */ (0,A.jsx)(Qv,{open:Pe,onOpenChange:Ve,trigger:e,keys:Oe}),Ue=He(/* @__PURE__ */ (0,A.jsx)(np,{variant:`quiet`,icon:`keyboard`,label:w(`鍵盤操作`),onClick:()=>Ie.current=!1})),We=C===`float`?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-cv-tools`,children:[ze,Be,Ue]}):C===!1?He(/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-cv-keyanchor`,"aria-hidden":`true`})):i||s||S?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-cv-head`,children:[i?a||o?/* @__PURE__ */ (0,A.jsx)(em,{href:a,onClick:o,className:`ui-cv-file`,children:i}):/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-cv-file`,children:i}):s?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-cv-title`,children:s}):null,ze,Be,Ue]}):He(/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-cv-keyanchor`,"aria-hidden":`true`}));return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-cv`,!T&&`no-nums`,C===`float`&&`is-float`,j),role:`region`,"aria-label":i||s||w(`原始碼`),children:[We,/* @__PURE__ */ (0,A.jsx)(`pre`,{ref:ye,style:b?{maxHeight:b}:void 0,tabIndex:0,"aria-label":w(`程式碼`),"aria-keyshortcuts":[...Oe.map(e=>e.k),`?`].join(` `),onKeyDown:ke,onCopy:je,onClick:B?void 0:Ae,...B?{onClick:e=>{ce(e),Ae(e)},onPointerEnter:()=>U.current=!0,onPointerLeave:()=>{U.current=!1,H(!1)},onPointerMove:e=>{let t=e.ctrlKey||e.metaKey;t!==V&&H(t)},onPointerOver:e=>{let t=oe(e.target);t&&e.pointerType===`mouse`&&K(t)},onPointerOut:e=>{let t=oe(e.target);t&&!t.contains(e.relatedTarget)&&q()},onFocus:e=>{let t=oe(e.target);t&&t.matches(`:focus-visible`)&&K(t)},onBlur:e=>{oe(e.target)&&q()}}:null,className:M(`ui-cv-body`,V&&`is-armed`),children:/* @__PURE__ */ (0,A.jsx)(`code`,{role:`list`,children:De})}),g&&ne&&m?.[ne.i]?/* @__PURE__ */ (0,A.jsx)(K_,{open:!0,onOpenChange:e=>e?void 0:W(null),children:/* @__PURE__ */ (0,A.jsx)(Y_,{children:/* @__PURE__ */ (0,A.jsx)(Q_,{anchor:ne.el,side:`bottom`,align:`start`,sideOffset:6,className:`ui-float`,children:/* @__PURE__ */ (0,A.jsx)($_,{id:re,className:`ui-popover ui-cv-preview`,onPointerEnter:ae,onPointerLeave:q,children:g(m[ne.i])})})})}):null,ue&&he?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn ui-cv-more`,onClick:()=>fe(!de),children:/* @__PURE__ */ (0,A.jsx)(`span`,{children:de?w(`只顯示第 {n} 行前後`,{n:le}):F(w(`顯示全部 {n} 行`,{n:``}),[P.length])})}):null]})}Er(),xt(),Sr(),Ct(),Ft(),cn(),ti(Tr,bt,xr,St,Pt,sn);let ey={頁面:`file-text`,設定:`gear`,指令:`command`,檔案:`file-code`};function ty(e,t){let n=e.label.toLowerCase().indexOf(t);return n===0?[0,0]:n>0?[1,n]:[e.detail,e.kind,...e.keywords??[]].join(` `).toLowerCase().includes(t)?[2,-1]:null}function ny(e){let{open:t,onOpenChange:n,items:r,onSelect:i,placeholder:a,recent:o,recentLabel:s,emptyText:c,noResultsText:l,kinds:u,filter:d=!0,onQueryChange:f,loading:p,total:m,limit:h=50,hotkey:g=!0,defaultQuery:_=``,label:v}=e,[b,x]=y.useState(_),[S,C]=y.useState(0);Wm(t);let[T,E]=y.useState(t);t!==T&&(E(t),t&&(x(_),C(0)));let D=y.useRef(null),O=y.useId(),k=y.useRef(n),j=y.useRef(f);y.useLayoutEffect(()=>{k.current=n,j.current=f}),y.useEffect(()=>{t&&j.current?.(_)},[t,_]),y.useEffect(()=>{if(!g)return;let e=e=>{(e.ctrlKey||e.metaKey)&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`k`&&(e.preventDefault(),k.current(!t))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[g,t]);let N=b.trim().toLowerCase(),P=(d===!1?r.map(e=>({it:e,at:-1})):N?r.map((e,t)=>{let n=ty(e,N);return n?{it:e,rank:n[0],at:n[1],i:t}:null}).filter(e=>e!==null).sort((e,t)=>e.rank-t.rank||e.i-t.i):(o??[]).map(e=>({it:e,at:-1}))).slice(0,h),F=Math.min(S,Math.max(0,P.length-1));y.useEffect(()=>{D.current?.querySelector(`.is-active`)?.scrollIntoView?.({block:`nearest`})},[F,t]);let I=e=>{n(!1),i?.(e)},L=e=>{if(!(e.nativeEvent.isComposing||e.keyCode===229)){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;C(P.length?(F+t+P.length)%P.length:0)}else e.key===`Enter`&&(e.preventDefault(),P[F]&&I(P[F].it))}},R=(e,t)=>{let n=e.label;return/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-pal-label`,e.code&&`is-code`),children:t>=0&&N?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[n.slice(0,t),/* @__PURE__ */ (0,A.jsx)(`mark`,{className:`ui-pal-hit`,children:n.slice(t,t+N.length)}),n.slice(t+N.length)]}):n})},z=N?(e=>typeof l==`function`?l(e):(l??w(`找不到符合「{q}」的結果`)).replace(`{q}`,e))(b.trim()):c||w(`輸入名稱開始搜尋`),B=m!=null&&m>P.length?m-P.length:0,V=B?w(`顯示 {n} 筆,另有 {m} 筆,請輸入更長的字`,{n:P.length,m:B}):w(`共 {n} 筆`,{n:P.length}),H=t&&N?p?w(`搜尋中`):P.length?B?V:w(`找到 {n} 筆結果`,{n:P.length}):z:``;return y.useEffect(()=>{if(!H)return;let e=setTimeout(()=>bi(H),400);return()=>clearTimeout(e)},[H,N,p]),/* @__PURE__ */ (0,A.jsx)(Vp,{open:t,onOpenChange:n,children:/* @__PURE__ */ (0,A.jsxs)(Cp,{children:[/* @__PURE__ */ (0,A.jsx)(cp,{className:`ui-pal-backdrop`}),/* @__PURE__ */ (0,A.jsxs)(xp,{className:`ui-pal`,"aria-label":v||w(`搜尋`),children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-pal-head`,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`magnifying-glass`,className:`ui-pal-icon`}),/* @__PURE__ */ (0,A.jsx)(`input`,{className:`ui-pal-input`,type:`text`,value:b,placeholder:a||w(`搜尋`),role:`combobox`,"aria-expanded":P.length>0,"aria-controls":P.length?O:void 0,"aria-autocomplete":`list`,"aria-activedescendant":P[F]?`${O}-${F}`:void 0,autoComplete:`off`,spellCheck:!1,enterKeyHint:`go`,onChange:e=>{x(e.target.value),C(0),f?.(e.target.value)},onKeyDown:L}),/* @__PURE__ */ (0,A.jsx)(gp,{className:`ui-pal-cancel`,children:w(`取消`)})]}),!N&&P.length&&o?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-pal-group`,children:s||w(`最近開啟`)}):null,P.length?/* @__PURE__ */ (0,A.jsx)(`ul`,{ref:D,id:O,className:`ui-pal-list`,role:`listbox`,"aria-label":w(`搜尋結果`),children:P.map(({it:e,at:t},n)=>/* @__PURE__ */ (0,A.jsxs)(`li`,{id:`${O}-${n}`,role:`option`,"aria-selected":n===F,className:M(`ui-pal-item`,n===F&&`is-active`),onMouseMove:()=>F!==n&&C(n),onMouseDown:e=>e.preventDefault(),onClick:()=>I(e),children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-pal-kind`,title:e.kind,children:/* @__PURE__ */ (0,A.jsx)(fi,{icon:e.icon??(e.kind?u?.[e.kind]??ey[e.kind]:void 0)??`file`,size:16})}),/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-pal-text`,children:[/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-pal-line`,children:[e.kind?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:e.kind+` `}):null,R(e,t)]}),e.detail?/* @__PURE__ */ (0,A.jsx)(rm,{className:`ui-pal-detail`,text:e.detail}):null]})]},e.id??n))}):/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-pal-empty`,children:p?w(`搜尋中`):z}),p&&P.length?/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-pal-loading`,children:w(`搜尋中`)}):null,N&&!p&&P.length?/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-pal-count`,"aria-hidden":`true`,children:V}):null,/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-pal-keys`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsxs)(`span`,{children:[/* @__PURE__ */ (0,A.jsx)(`kbd`,{children:`↑`}),/* @__PURE__ */ (0,A.jsx)(`kbd`,{children:`↓`}),w(`選擇`)]}),/* @__PURE__ */ (0,A.jsxs)(`span`,{children:[/* @__PURE__ */ (0,A.jsx)(`kbd`,{children:`Enter`}),w(`打開`)]}),/* @__PURE__ */ (0,A.jsxs)(`span`,{children:[/* @__PURE__ */ (0,A.jsx)(`kbd`,{children:`Esc`}),w(`關閉`)]})]})]})]})})}function ry({title:e,description:t,actionLabel:n,onAction:r,confirm:i,className:a}){let o=n||w(`刪除`);return/* @__PURE__ */ (0,A.jsxs)(`section`,{className:M(`ui-danger`,a),children:[/* @__PURE__ */ (0,A.jsx)(`h2`,{className:`ui-danger-title`,children:e||w(`危險操作`)}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-danger-row`,children:[/* @__PURE__ */ (0,A.jsx)(`p`,{children:im(t)}),/* @__PURE__ */ (0,A.jsx)(Xp,{variant:`danger`,confirm:i??{title:w(`{label}?`,{label:o})},onClick:r,children:o})]})]})}cn(),ir(),ti(sn,rr);function iy({value:e,onChange:t,className:n,label:r,...i}){let a=y.useRef(null);return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-searchfield`,n),children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`magnifying-glass`,size:16,className:`ui-searchfield-icon`}),/* @__PURE__ */ (0,A.jsx)(`input`,{ref:a,type:`search`,"aria-label":r||w(`搜尋`),...i,className:`ui-input`,value:e,onChange:e=>t(e.target.value)}),e?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-searchfield-clear`,"aria-label":w(`清除搜尋`),onClick:()=>{t(``),a.current?.focus()},children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`,size:12})}):null]})}function ay({items:e,value:t,onChange:n,label:r,unit:i,hideUnit:a=!1,className:o}){let s=y.useRef([]),c=y.useRef(null),[l,u]=y.useState(null),[d,f]=y.useState(!0),[p,m]=gi(),[h,g]=y.useState({left:!1,right:!1}),_=y.useCallback(()=>{let e=c.current;if(!e)return;let t=e.scrollLeft>1,n=s.current.filter(Boolean).pop(),r=n?n.offsetLeft+n.offsetWidth:e.scrollWidth,i=e.scrollLeft+e.clientWidth<r-1;g(e=>e.left===t&&e.right===i?e:{left:t,right:i})},[]);Gm(c,()=>s.current[Math.max(0,e.findIndex(e=>e.id===t))]),G(e.some(e=>e.count!=null&&!(e.unit||i)),`Tabs`,`a count has no unit, so it reads as a bare number. Pass unit, e.g. unit: '筆', on Tabs or on the item.`);let v=Math.max(0,e.findIndex(e=>e.id===t));y.useLayoutEffect(()=>{let e=s.current[v],t=c.current;if(!e||!t)return;let n=()=>{u({left:e.offsetLeft,right:t.clientWidth-e.offsetLeft-e.offsetWidth}),_()};n(),e.offsetLeft<t.scrollLeft?t.scrollLeft=e.offsetLeft-4:e.offsetLeft+e.offsetWidth>t.scrollLeft+t.clientWidth&&(t.scrollLeft=e.offsetLeft+e.offsetWidth-t.clientWidth+4);let r=U(n);r?.observe(t);for(let e of s.current)e&&r?.observe(e);return()=>r?.disconnect()},[v,e.length,_]);let b=t=>{t!==v&&e[t]&&(f(t>v),m(),n?.(e[t].id),bi(e[t].label+(e[t].count==null?``:` `+p_.number(e[t].count??0)+(e[t].unit||i?` `+T(e[t].unit||i,e[t].count??0):``))))};return/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:c,className:M(`ui-tabs`,h.left&&`has-more-left`,h.right&&`has-more-right`,o),role:`tablist`,"aria-label":r,onScroll:_,children:[l?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tabs-ind`,"aria-hidden":`true`,style:{left:l.left,right:l.right,transform:p?`scaleY(.82)`:`none`,transition:hi(`left`,`right`,d)}}):null,e.map((t,n)=>/* @__PURE__ */ (0,A.jsxs)(`button`,{ref:e=>{s.current[n]=e},type:`button`,role:`tab`,"aria-selected":n===v,tabIndex:n===v?0:-1,className:M(`ui-tab`,n===v&&`is-selected`),onClick:()=>b(n),onKeyDown:t=>{if(W(t))return;let r=t.key===`ArrowRight`?(n+1)%e.length:t.key===`ArrowLeft`?(n-1+e.length)%e.length:-1;r<0||(t.preventDefault(),s.current[r]?.focus(),b(r))},children:[t.label,t.count==null?null:` `,t.count==null?null:/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-tab-count`,children:[p_.number(t.count),t.unit||i?a?/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-visually-hidden`,children:[` `,T(t.unit||i,t.count)]}):/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[` `,/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-unit`,children:T(t.unit||i,t.count)})]}):null]})]},t.id))]})}J(),ti(le);function oy(){let e=y.useRef(null),[t,n]=y.useState(!1),[r,i]=y.useState(!1),[a,o]=y.useState(!1),s=y.useCallback(()=>{let t=e.current;if(!t)return;let r=t.scrollWidth>t.clientWidth+1;o(r),n(r&&t.scrollLeft+t.clientWidth<t.scrollWidth-1)},[]);return y.useLayoutEffect(()=>{let t=e.current;if(!t)return;s();let n=U(s);n?.observe(t),t.firstElementChild&&n?.observe(t.firstElementChild);let r=0,i=()=>{cancelAnimationFrame(r),r=requestAnimationFrame(s)},a=new MutationObserver(i);return a.observe(t,{childList:!0,subtree:!0,characterData:!0}),document.fonts?.ready.then(i).catch(()=>{}),()=>{n?.disconnect(),a.disconnect(),cancelAnimationFrame(r)}},[s]),{ref:e,more:t,overflows:a,scrolled:r,onScroll:y.useCallback(()=>{let t=e.current;t&&t.scrollLeft>0&&i(!0),s()},[s]),measure:s}}function sy({show:e,done:t}){let n=H(`(pointer: coarse)`);return e?/* @__PURE__ */ (0,A.jsxs)(`span`,{className:M(`ui-scroll-hint`,t&&`is-done`),"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`arrow-right`,size:14}),w(n?`左右滑動`:`向右捲動`)]}):null}rt(),Te(),ti(nt,we);function cy(e){let[t,n]=y.useState(!1),r=y.useRef(null),i=e.min??48,a=t=>e.onWidth(Math.max(i,Math.round(t))),o=t=>{n(t),e.onDragging?.(t)};return/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-col-resize`,t&&`is-dragging`),role:`separator`,"aria-orientation":`vertical`,"aria-label":w(`調整「{name}」欄寬`,{name:e.name}),"aria-valuenow":Math.round(e.width),"aria-valuemin":i,tabIndex:0,onClick:e=>e.stopPropagation(),onPointerDown:t=>{t.button===0&&(t.preventDefault(),t.stopPropagation(),t.currentTarget.setPointerCapture?.(t.pointerId),r.current={x:t.clientX,w:e.start()},o(!0))},onPointerMove:e=>{r.current&&a(r.current.w+e.clientX-r.current.x)},onPointerUp:()=>{r.current=null,o(!1)},onPointerCancel:()=>{r.current=null,o(!1)},onDoubleClick:t=>{t.stopPropagation(),e.onReset()},onKeyDown:t=>{t.altKey||t.metaKey||t.ctrlKey||(t.key===`ArrowLeft`||t.key===`ArrowRight`?(t.preventDefault(),t.stopPropagation(),a(e.start()+(t.key===`ArrowRight`?16:-16))):t.key===`Enter`&&(t.preventDefault(),t.stopPropagation(),e.onReset()))}})}function ly({onClick:e,inToolbar:t}){return/* @__PURE__ */ (0,A.jsx)(np,{className:t?`ui-dt-zoombtn`:`ui-table-zoom`,icon:`corners-out`,label:w(`放大表格`),onClick:e})}function uy(e){return e.open?/* @__PURE__ */ (0,A.jsx)(am,{open:!0,onClose:e.onClose,title:e.title||w(`表格`),className:`ui-table-dialog`,children:/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-table-dialog-body`,onClick:t=>{if(t.metaKey||t.ctrlKey||t.shiftKey||t.button!==0)return;let n=t.target.closest(`a[href], [role="link"], .ui-code.is-link, .ui-md-link`);n&&t.currentTarget.contains(n)&&e.onClose()},children:e.children})}):null}function dy(e,t){let n=e=>e.replace(/\r?\n/g,` `).replace(/\|/g,`\\|`).trim();return[`| ${e.map(n).join(` | `)} |`,`|${e.map(()=>`---`).join(`|`)}|`,...t.map(e=>`| ${e.map(n).join(` | `)} |`)].join(`
82
+ `)}let fy=(e,t)=>e[t];function py(e,t){if(t==null||t===``)return`—`;let n=()=>t instanceof Date?t:new Date(t);if(e.format===`money`)return p_.money(Number(t),{currency:e.currency});if(e.format===`date`)return p_.date(n());if(e.format===`datetime`)return p_.dateTime(n());if(e.format===`relative`)return p_.relative(n());if(e.format===`duration`)return p_.duration(Number(t));let r=e.format===`percent`?p_.number(Number(t),e.decimals??`percent`):e.numeric&&typeof t==`number`?p_.number(t,e.decimals??(e.unit===`GB`||e.unit===`MB`?`size`:0)):String(t);return e.unit?`${r} ${e.unit}`:r}let my=[`date`,`datetime`,`relative`],hy=e=>my.includes(e.format??``);function gy(e){if(e==null||e===``)return null;let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?null:t}function _y(e,t){return e.map(e=>{let n=e.options;if((e.type??`list`)===`list`&&!n){let r=/* @__PURE__ */ new Set;n=[];for(let i of t){let t=fy(i,e.key);t!=null&&!r.has(String(t))&&(r.add(String(t)),n.push({value:String(t),label:String(t)}))}}return{...e,type:e.type??`list`,multiple:e.multiple??!0,options:n??[]}})}let vy=e=>!Array.isArray(e);function yy(e){return e?vy(e)?e.min!==``&&e.min!=null||e.max!==``&&e.max!=null:e.length>0:!1}function by(e,t,n){if(!n||!yy(n))return!0;if(e.match)return e.match(t,n);let r=fy(t,e.key);if(vy(n)){let t=e.scale||1,i=parseFloat(n.min),a=parseFloat(n.max),o=Number(r);return!(!Number.isNaN(i)&&o<i*t)&&!(!Number.isNaN(a)&&o>a*t)}return n.includes(String(r))}function xy(e,t,n,r,i){let a=r.toLowerCase();return t.some(t=>{if(i&&!i.includes(t.key))return!1;let r=fy(e,t.key),o=t.searchText?t.searchText(e):t.render?``:py(t,r),s=n.find(e=>e.key===t.key)?.options.find(e=>e.value===String(r));return s&&(o+=` `+s.label),!o&&t.render&&(o=r==null?``:String(r)),t.secondary&&(o+=` `+re(t.secondary(e))),o.toLowerCase().includes(a)})}let Sy=(e,t)=>(e?e+`.`:``)+t;function Cy(e,t){let n={},r=new URLSearchParams(location.search);for(let i of t)if(i.type===`range`){let t=r.get(Sy(e,i.key+`_min`)),a=r.get(Sy(e,i.key+`_max`));(t||a)&&(n[i.key]={min:t||``,max:a||``})}else{let t=r.get(Sy(e,i.key));t&&(n[i.key]=t.split(`,`))}return{q:r.get(Sy(e,`q`))||``,values:n}}function wy(e,t,n,r){let i=new URLSearchParams(location.search),a=(t,n)=>n?i.set(Sy(e,t),n):i.delete(Sy(e,t));a(`q`,r);for(let e of t){let t=n[e.key];e.type===`range`?(a(e.key+`_min`,t&&vy(t)?t.min:void 0),a(e.key+`_max`,t&&vy(t)?t.max:void 0)):a(e.key,t&&!vy(t)&&t.length?t.join(`,`):void 0)}let o=i.toString();history.replaceState(history.state,``,location.pathname+(o?`?`+o:``)+location.hash)}function Ty(e){let t=new URLSearchParams(location.search).get(Sy(e,`sort`));return t==null?null:t.split(`,`).filter(Boolean).map(e=>e.startsWith(`-`)?{key:e.slice(1),dir:`desc`}:{key:e,dir:`asc`})}function Ey(e,t,n){let r=new URLSearchParams(location.search),i=e=>e.map(e=>(e.dir===`desc`?`-`:``)+e.key).join(`,`);i(t)===i(n)?r.delete(Sy(e,`sort`)):r.set(Sy(e,`sort`),i(t));let a=r.toString();history.replaceState(history.state,``,location.pathname+(a?`?`+a:``)+location.hash)}pe(),Fe(),cr(),rt(),Te(),lt(),jt(),ir(),ti(fe,Pe,sr,nt,we,ct,At,rr);function Dy(e,t){if(!t||typeof e!=`string`)return e;let n=e.toLowerCase().indexOf(t.toLowerCase());return n<0?e:/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[e.slice(0,n),/* @__PURE__ */ (0,A.jsx)(`mark`,{className:`ui-mark`,children:e.slice(n,n+t.length)}),e.slice(n+t.length)]})}function Oy({columns:e,onCopy:t,onZoom:n}){if(!e&&!t&&!n)return null;let r=w(`更多表格操作`);return/* @__PURE__ */ (0,A.jsxs)(fg,{children:[/* @__PURE__ */ (0,A.jsx)(Zf,{label:r,describe:!1,children:/* @__PURE__ */ (0,A.jsx)(Sg,{className:M(`ui-iconbtn`,`is-quiet`,`ui-menu-trigger`,`ui-dt-menubtn`),"aria-label":r,children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`dots-three`,size:20})})}),/* @__PURE__ */ (0,A.jsx)(Fh,{children:/* @__PURE__ */ (0,A.jsx)(Gh,{className:`ui-float`,side:`bottom`,align:`end`,sideOffset:4,children:/* @__PURE__ */ (0,A.jsxs)(Mh,{className:`ui-menu ui-dt-moremenu`,children:[e?/* @__PURE__ */ (0,A.jsxs)(mg,{children:[/* @__PURE__ */ (0,A.jsxs)(kg,{className:`ui-menu-item`,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`columns`,size:16}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-menu-label`,children:w(`欄位`)}),/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-right`,size:16,className:`ui-dt-subcaret`})]}),/* @__PURE__ */ (0,A.jsx)(Fh,{children:/* @__PURE__ */ (0,A.jsx)(Gh,{className:`ui-float`,side:`left`,align:`start`,sideOffset:4,alignOffset:-6,children:/* @__PURE__ */ (0,A.jsxs)(Mh,{className:`ui-menu ui-dt-colmenu`,"aria-label":w(`顯示的欄位`),children:[/* @__PURE__ */ (0,A.jsxs)(vh,{children:[/* @__PURE__ */ (0,A.jsx)(yh,{className:`ui-noti-group`,children:w(`顯示的欄位`)}),e.cols.map((t,n)=>{let r=n===0||!e.hidden[t.key];return/* @__PURE__ */ (0,A.jsxs)(mh,{checked:r,disabled:n===0,closeOnClick:!1,className:`ui-menu-item`,onCheckedChange:()=>e.onToggle(t.key),children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-check-box`,r&&`is-on`),"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(P_,{v:r})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-menu-label`,children:t.label})]},t.key)})]}),/* @__PURE__ */ (0,A.jsx)(Tg,{className:`ui-menu-sep`}),/* @__PURE__ */ (0,A.jsxs)(xh,{className:`ui-menu-item`,closeOnClick:!1,onClick:e.onReset,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`arrow-u-up-left`,size:16}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-menu-label`,children:w(`還原預設`)})]})]})})})]}):null,t?/* @__PURE__ */ (0,A.jsxs)(xh,{className:`ui-menu-item`,onClick:t,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`copy`,size:16}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-menu-label`,children:w(`複製成 Markdown`)})]}):null,n?/* @__PURE__ */ (0,A.jsxs)(xh,{className:`ui-menu-item`,onClick:n,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`corners-out`,size:16}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-menu-label`,children:w(`放大表格`)})]}):null]})})})]})}function ky({chips:e,onClear:t,filterButton:n}){let r=y.useRef(null);if(!e.length)return null;let i=e=>requestAnimationFrame(()=>{let t=r.current?.querySelectorAll(`.ui-dt-chip`);(t?.[Math.min(e,t.length-1)]??n())?.focus()});return/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:r,className:`ui-dt-chips`,role:`group`,"aria-label":w(`套用的篩選`),children:[e.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:`ui-dt-chip`,"aria-label":w(`移除篩選:{name}`,{name:e.text}),onClick:()=>{e.remove(),i(t)},children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-chip-text`,children:e.text}),/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`,size:16})]},e.id)),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn ui-dt-chipclear`,onClick:()=>{t(),requestAnimationFrame(()=>n()?.focus())},children:w(`清除全部`)})]})}function Ay({filters:e,values:t,activeCount:n,count:r,onChange:i,onClear:a,boundary:o}){let[s,c]=y.useState(!1);return/* @__PURE__ */ (0,A.jsxs)(wv,{open:s,onOpenChange:c,boundary:o,className:`ui-dt-filterpop`,"aria-label":w(`篩選`),trigger:/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-btn`,`ui-btn-secondary`,`ui-dt-filterbtn`,s&&`is-open`,n>0&&`is-active`),"aria-label":n?w(`篩選,已套用 {n} 個條件`,{n}):void 0,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`funnel`,size:20}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-btntext`,children:w(`篩選`)}),n?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-pop-count`,children:n}):null]}),children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-filterhead`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-popover-title`,children:w(`篩選`)}),n?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn`,onClick:a,children:w(`清除全部`)}):null]}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dt-facets`,children:e.map(e=>{let n=t[e.key];if(e.type===`range`){let t=n&&!Array.isArray(n)?n:{min:``,max:``},r=n=>r=>i(e.key,{...t,[n]:r.target.value.replace(/[^\d.]/g,``)});return/* @__PURE__ */ (0,A.jsxs)(`fieldset`,{className:`ui-dt-facet`,children:[/* @__PURE__ */ (0,A.jsx)(`legend`,{children:e.label}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-range-inputs`,children:[/* @__PURE__ */ (0,A.jsx)(`input`,{className:`ui-input`,inputMode:`decimal`,"aria-label":`${e.label} ${w(`最低`)}`,placeholder:w(`最低`),value:t.min,onChange:r(`min`)}),/* @__PURE__ */ (0,A.jsx)(`span`,{children:`–`}),/* @__PURE__ */ (0,A.jsx)(`input`,{className:`ui-input`,inputMode:`decimal`,"aria-label":`${e.label} ${w(`最高`)}`,placeholder:w(`最高`),value:t.max,onChange:r(`max`)})]}),e.unitLabel?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-field-hint`,children:e.unitLabel}):null]},e.key)}let a=Array.isArray(n)?n:[];return/* @__PURE__ */ (0,A.jsxs)(`fieldset`,{className:`ui-dt-facet`,children:[/* @__PURE__ */ (0,A.jsx)(`legend`,{children:e.label}),e.options.map(t=>{let n=String(t.value),o=a.includes(n),s=r(e,n),c=e.multiple?o?a.filter(e=>e!==n):[...a,n]:o?[]:[n];return/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,role:e.multiple?`checkbox`:`radio`,"aria-checked":o,className:M(`ui-dt-opt`,o&&`is-on`,!s&&!o&&`is-zero`),onClick:()=>i(e.key,c),children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(e.multiple?`ui-check-box`:`ui-radio-ring`,o&&`is-on`),"aria-hidden":`true`,children:e.multiple?/* @__PURE__ */ (0,A.jsx)(P_,{v:o}):o?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-radio-dot`}):null}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-opt-label`,children:t.label}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-opt-n`,children:p_.number(s)})]},t.value)})]},e.key)})})]})}function jy({text:e,children:t}){let n=H(B);return/* @__PURE__ */ (0,A.jsx)(Zf,{label:e,wrap:!0,describe:!1,disabled:n||!e,children:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-full`,children:t})})}function My({children:e}){let t=y.useRef(null),n=y.useRef(null),r=ee(),i=H(B),[a,o]=y.useState(!1),[s,c]=y.useState(!1),[l,u]=y.useState(``);y.useLayoutEffect(()=>{let e=n.current,o=t.current;if(!e||!o||a)return;let s=()=>{c(e.scrollHeight>e.clientHeight+1),u(!r&&!i&&o.scrollWidth>o.clientWidth+1?o.textContent??``:``)};s();let l=U(s);return l?.observe(o),()=>l?.disconnect()},[a,e,r,i]);let d=/* @__PURE__ */ (0,A.jsxs)(`span`,{ref:t,className:M(`ui-dt-long`,!!l&&`is-cut`),tabIndex:l?0:void 0,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{ref:n,className:M(`ui-dt-long-text`,!a&&`is-clamped`),children:e}),r&&(s||a)?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-dt-more`,onClick:e=>{e.stopPropagation(),o(!a)},children:w(a?`收合`:`顯示全部`)}):null]});return/* @__PURE__ */ (0,A.jsx)(Zf,{label:l,wrap:!0,disabled:!l,children:d})}Mr(),bn(),Ar(),ir(),ti(jr,yn,kr,rr);let Ny=e=>w(e===`asc`?`由小到大`:`由大到小`),Py={asc:`↑`,desc:`↓`};function Fy(e,t){if(!e.length)return w(`已還原原本的順序`);let n=e=>t.find(t=>t.key===e)?.label??e;return w(`依 {list} 排序`,{list:e.map(e=>n(e.key)+` `+Ny(e.dir)).join(w(`,再依 `))})}function Iy({cols:e,levels:t,max:n,onChange:r,boundary:i}){let[a,o]=y.useState(!1),[s,c]=y.useState(!1),[l,u]=y.useState(null),d=y.useRef(null),f=y.useRef(null),p=y.useId();y.useEffect(()=>{s&&f.current?.focus()},[s]);let m=t=>e.find(e=>e.key===t)?.label??t,h=t=>e.find(e=>e.key===t)?.numeric?`desc`:`asc`,g=e.filter(e=>!t.some(t=>t.key===e.key)),_=(e,n,i)=>{if(n<0||n>=t.length||e===n)return;let a=t.slice();a.splice(n,0,a.splice(e,1)[0]),r(a),i&&requestAnimationFrame(()=>d.current?.querySelectorAll(`.ui-dt-sortgrip`)[n]?.focus())},v=t.map(e=>m(e.key)+` `+Py[e.dir]).join(w(`、`)),b=t.map(e=>m(e.key)+` `+Ny(e.dir)).join(w(`、`));return/* @__PURE__ */ (0,A.jsxs)(wv,{open:a,onOpenChange:e=>{o(e),e||c(!1)},boundary:i,className:`ui-dt-sortpop`,"aria-label":w(`排序`),trigger:/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-btn`,`ui-btn-secondary`,`ui-dt-sortbtn`,a&&`is-open`,t.length>0&&`is-on`),"aria-label":t.length?w(`排序:{list}`,{list:b}):w(`排序`),children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`sort-ascending`,size:20}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-sortbtn-text`,children:t.length?w(`排序:{list}`,{list:v}):w(`排序`)}),t.length?/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-dt-sortbtn-short`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-btntext`,children:w(`排序`)}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-pop-count`,children:t.length})]}):null]}),children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-filterhead`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-popover-title`,children:w(`排序`)}),t.length?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn`,onClick:()=>r([]),children:w(`清除全部`)}):null]}),t.length?/* @__PURE__ */ (0,A.jsx)(`ol`,{className:`ui-dt-sortlist`,ref:d,children:t.map((e,n)=>/* @__PURE__ */ (0,A.jsxs)(`li`,{className:M(`ui-dt-sortlvl`,l?.from===n&&`is-dragging`,l&&l.over===n&&l.from!==n&&`is-over`),draggable:!0,onDragStart:e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(n)),u({from:n,over:n})},onDragOver:e=>{e.preventDefault(),l&&l.over!==n&&u({...l,over:n})},onDrop:e=>{e.preventDefault(),l&&_(l.from,n),u(null)},onDragEnd:()=>u(null),children:[/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-dt-sortgrip`,"aria-label":w(`「{name}」第 {n} 排序;按 Alt+↑ ↓ 調整順序`,{name:m(e.key),n:n+1}),"aria-keyshortcuts":`Alt+ArrowUp Alt+ArrowDown`,onKeyDown:e=>{!e.altKey||e.key!==`ArrowUp`&&e.key!==`ArrowDown`||(e.preventDefault(),_(n,n+(e.key===`ArrowUp`?-1:1),!0))},children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`dots-six-vertical`,size:16})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-sortn`,children:n+1}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-sortname`,children:m(e.key)}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-sortdir`,role:`radiogroup`,"aria-label":w(`「{name}」的方向`,{name:m(e.key)}),children:[`asc`,`desc`].map(i=>/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e.dir===i,className:M(e.dir===i&&`is-on`),onClick:()=>r(t.map((e,t)=>t===n?{key:e.key,dir:i}:e)),children:[Py[i],` `,Ny(i)]},i))}),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-dt-sortrm`,"aria-label":w(`移除「{name}」排序`,{name:m(e.key)}),onClick:()=>r(t.filter((e,t)=>t!==n)),children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`,size:16})})]},e.key))}):/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-dt-sortnone`,children:w(`照資料原本的順序。`)}),g.length&&t.length<n?s?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-sortadd`,role:`group`,"aria-labelledby":p,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{id:p,className:`ui-dt-sortaddhead`,children:t.length?w(`再依哪一欄`):w(`依哪一欄排序`)}),g.map((e,n)=>/* @__PURE__ */ (0,A.jsxs)(`button`,{ref:n===0?f:void 0,type:`button`,className:`ui-dt-opt`,onClick:()=>{r([...t,{key:e.key,dir:h(e.key)}]),c(!1)},children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`plus`,size:16}),e.label]},e.key))]}):/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:`ui-link-btn ui-dt-sortmore`,onClick:()=>c(!0),children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`plus`,size:16}),t.length?w(`再依…`):w(`排序依據…`)]}):t.length>=n&&g.length?/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-dt-sortnone`,children:w(`最多 {n} 層排序。`,{n})}):null]})}Fe(),qe(),ir(),ti(Pe,Ke,rr);let Ly={dur:320,stagger:25,ease:`cubic-bezier(.2,.8,.2,1)`},Ry={asc:`M12 19V5M6 11l6-6 6 6`,desc:`M12 5v14M6 13l6 6 6-6`,none:`M8 9l4-4 4 4M8 15l4 4 4-4`},zy=(e,t)=>e[t],By=e=>e.numeric||e.format===`money`||e.format===`percent`||e.format===`duration`,Vy=e=>By(e)||!!e.unit||hy(e)||e.mobile===`status`,Hy=(e,t)=>t?`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`:e.toISOString();function Uy(e){let t=1/0,n=-1/0,r=document.createRange();if(typeof r.getBoundingClientRect!=`function`)return null;for(let i of e.childNodes){let e=null;if(i instanceof HTMLElement){if(i.classList.contains(`ui-col-resize`)||getComputedStyle(i).position===`absolute`)continue;e=i.getBoundingClientRect()}else i.nodeType===Node.TEXT_NODE&&i.textContent?.trim()&&(r.selectNodeContents(i),e=r.getBoundingClientRect());e&&e.width&&(t=Math.min(t,e.left),n=Math.max(n,e.right))}return n>t?n-t:0}let Wy=/* @__PURE__ */ new Set,Gy=/* @__PURE__ */ new Set,Ky=null,qy=()=>Gy.forEach(e=>e());function Jy(e){if(!e.isConnected||e.closest(`[inert], [aria-hidden="true"]`))return!1;let t=e.checkVisibility;return typeof t==`function`?t.call(e,{checkVisibilityCSS:!0,visibilityProperty:!0}):e.getClientRects().length>0&&getComputedStyle(e).visibility!==`hidden`}let Yy=e=>e.querySelector(`:scope > .ui-dt-tools .ui-dt-search input`),Xy=()=>[...Wy].filter(e=>Jy(e)&&!!Yy(e)).sort((e,t)=>e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)[0]??null;function Zy(e){if(e.key!==`/`||e.ctrlKey||e.metaKey||e.altKey||e.defaultPrevented||e.isComposing||(e.target instanceof Element?e.target:null)?.closest(`input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="textbox"], [role="searchbox"], [role="combobox"], [role="listbox"], [role="grid"], [role="treegrid"], [role="tree"], [role="menu"], [role="menubar"], [role="dialog"], [role="alertdialog"], dialog`))return;let t=Xy(),n=t?Yy(t):null;n&&(n.focus(),document.activeElement===n&&e.preventDefault())}function Qy(e,t){return Wy.size||document.addEventListener(`keydown`,Zy),!Ky&&typeof ResizeObserver<`u`&&(Ky=new ResizeObserver(qy)),Wy.add(e),Gy.add(t),Ky?.observe(e),qy(),()=>{Wy.delete(e),Gy.delete(t),Ky?.unobserve(e),Wy.size||(document.removeEventListener(`keydown`,Zy),Ky?.disconnect(),Ky=null),qy()}}let $y=e=>e.ctrlKey||e.metaKey||e.shiftKey||e.button===1,eb=`a, button, input, select, textarea, label, [role="checkbox"], [role="button"], [role="menuitem"], [role="link"], [contenteditable]`;function tb({v:e,label:t,onClick:n}){return/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,"aria-label":t,className:M(`ui-check-box`,`ui-dt-check`,e&&`is-on`),onMouseDown:e=>e.shiftKey&&e.preventDefault(),onClick:e=>{e.stopPropagation(),n(e)},children:/* @__PURE__ */ (0,A.jsx)(P_,{v:e})})}function nb(e){let{columns:t,rows:n,pageSize:r=10,urlSync:i=!0,urlKey:a,search:o={},selectable:s=!1,stickyFirst:c=!1}=e,l=y.useMemo(()=>{let r=e.filters?[...e.filters]:[];return e.filter&&!r.length&&r.push({key:e.filter.key,label:e.filter.label||t.find(t=>t.key===e.filter?.key)?.label||e.filter.key,options:e.filter.options}),_y(r,n)},[e.filters,e.filter,t,n]),u=()=>i&&typeof location<`u`?Cy(a,l):{q:``,values:{}},d=Math.max(1,e.maxSort??1/0),f=t.filter(e=>e.sortable!==!1).map(e=>({key:e.key,label:e.label,numeric:By(e)})),p=e=>f.find(t=>t.key===e)?.numeric?`desc`:`asc`,m=e=>e.filter((t,n)=>f.some(e=>e.key===t.key)&&e.findIndex(e=>e.key===t.key)===n).slice(0,d).map(e=>({key:e.key,dir:e.dir??p(e.key)})),h=m(e.defaultSort??[]),[g,_]=y.useState(()=>m((i&&typeof location<`u`?Ty(a):null)??h)),[v,x]=y.useState(0),[S,C]=y.useState(()=>u().q),[E,D]=y.useState(()=>u().values),[O,k]=y.useState(e.views?.[0]?.id??null),P=e.widthKey?`ui-dt-cols:`+e.widthKey:null,[I,R]=y.useState(()=>{if(!P)return{};try{let e=JSON.parse(localStorage.getItem(P)||`null`);return e&&typeof e==`object`?e:{}}catch{return{}}}),z=e=>{if(R(e),P)try{Object.keys(e).length?localStorage.setItem(P,JSON.stringify(e)):localStorage.removeItem(P)}catch{}},[V,ne]=y.useState({}),W=ee(),re=H(B),ie=y.useId(),K=y.useRef(null),[q,ae]=y.useState({}),[oe,se]=y.useState(`all`),[ce,le]=y.useState({}),[J,ue]=y.useState(null),[de,fe]=y.useState({}),pe=y.useRef(de),[me,he]=y.useState(!1),[ge,_e]=y.useState(null),[ve,ye]=y.useState(!1),[be,xe]=y.useState(()=>{if(!e.widthKey)return null;try{let t=JSON.parse(localStorage.getItem(`ui-dt-width:`+e.widthKey)||`null`);return t&&typeof t==`object`?t:null}catch{return null}}),Se=t=>{if(xe(t),e.widthKey)try{t?localStorage.setItem(`ui-dt-width:`+e.widthKey,JSON.stringify(t)):localStorage.removeItem(`ui-dt-width:`+e.widthKey)}catch{}},[Ce,we]=y.useState(!1),[Te,Ee]=y.useState(null),De=y.useRef(null),[Oe,ke]=y.useState(null),Ae=o===!1&&!e.caption;y.useLayoutEffect(()=>{let e=Ae?K.current?.previousElementSibling:null;ke(e instanceof HTMLElement&&e.classList.contains(`ui-card-head`)&&e.parentElement?.classList.contains(`ui-card`)?e:null)},[Ae]),y.useEffect(()=>{let e=K.current?.previousElementSibling;G(e?.classList.contains(`ui-card-head`)&&!e.querySelector(`.ui-card-title`)&&e.querySelector(`.ui-card-actions`),`DataTable`,`the Card around this table has actions but no title, so its one button takes a row of its own above the table. Pass the page's primary action to DataTable's action instead: it goes at the right end of the toolbar.`)},[]);let[je,Me]=y.useState(e.resetKey),Ne=je!==e.resetKey;Ne&&(Me(e.resetKey),C(``),D({}),x(0),ae({}),se(`all`),_(h),P||R({}),ne({}),le({}),fe({}),ue(null));let Pe=JSON.stringify(E),Fe=JSON.stringify(g);y.useEffect(()=>{i&&typeof location<`u`&&Ey(a,g,h)},[Fe]),y.useEffect(()=>{i&&l.length&&wy(a,l,E,S)},[Pe,S]),G(t.some(e=>e.format===`percent`&&!e.unit),`DataTable`,`format: 'percent' sets 1 decimal and shows no % sign; add unit: '%' to that column.`),G(n.length>1&&n.every(e=>zy(e,`id`)==null)&&s,`DataTable`,`rows have no id, so a selection follows the position, not the row. Add an id to each row.`),G(!!t[0]?.hidden,`DataTable`,`the first column is always shown, so its hidden: true does nothing. Move the column, or drop hidden.`),G((e.columnMenu===!1||t.length<=2)&&t.some((e,t)=>t>0&&e.hidden),`DataTable`,`a column has hidden: true but there is no 「欄位」 menu (columnMenu is false, or the table has 2 columns or fewer), so nobody can turn it on. Turn the menu on, or leave the column out.`);let Ie=e.summary?.key,Le=Ie?l.find(e=>e.key===Ie):void 0;G(Le,`DataTable`,`the filter 「${Le?.label}」 filters ${String(Ie)}, which the summary tabs already filter, so the same condition is in two places. Drop it from filters (or drop summary).`);let Re=Ie&&n.length?e.views?.find(e=>{if(!e.filter)return!1;let t=n.filter(t=>e.filter?.(t));if(!t.length||t.length===n.length)return!1;let r=String(zy(t[0],Ie));return t.every(e=>String(zy(e,Ie))===r)&&n.filter(e=>String(zy(e,Ie))===r).length===t.length}):void 0;G(Re,`DataTable`,`the view 「${Re?.label}」 keeps exactly the rows of one ${String(Ie)} value, which a summary tab already picks, so the same condition is in two places. Drop the view (or drop summary).`);for(let e of t){if(!e.unit&&!e.numeric)continue;let t=n.map(t=>zy(t,e.key)).find(t=>typeof t==`string`&&/\d/.test(t)&&(e.unit?t.includes(e.unit):!/^\s*-?[\d,]*\.?\d+\s*$/.test(t)));G(t!==void 0,`DataTable`,`column 「${e.label}」 got the string 「${String(t)}」. Pass a number${e.unit?``:` and the unit in unit`} (e.g. { numeric: true, unit: '${e.unit||`字`}' } with 1234), so it is formatted, right-aligned and sorted as a number.`)}let ze={};t.forEach((e,t)=>ze[e.key]=t>0&&(I[e.key]??!!e.hidden));let Be=t.filter(e=>!ze[e.key]),{ref:Ve,more:He,overflows:Ue,scrolled:We,onScroll:Ge}=oy(),Ke=y.useRef(null),qe=y.useRef({}),Je=y.useRef(null),Ye=n.map((e,t)=>({r:e,i:t})),Xe=e.views?.find(e=>e.id===O);Xe?.filter&&(Ye=Ye.filter(e=>Xe.filter?.(e.r)));let Ze=Ye,Qe=e.summary;Qe&&oe!==`all`&&(Ye=Ye.filter(e=>String(zy(e.r,Qe.key))===oe));let $e=Ye.length,et=o!==!1&&!!S,tt=(e,n)=>(!et||xy(e,t,l,S,o?o.keys:void 0))&&l.every(t=>t.key===n||by(t,e,E[t.key])),nt=Ye.filter(e=>tt(e.r)),rt=l.filter(e=>yy(E[e.key])).length;if(g.length){let e=g.map(e=>{let n=t.find(t=>t.key===e.key);return{val:t=>{if(n?.sortValue)return n.sortValue(t);let r=zy(t,e.key);return r instanceof Date||n&&hy(n)?gy(r)?.getTime()??-1/0:r},d:e.dir===`asc`?1:-1}});nt=[...nt].sort((t,n)=>{for(let{val:r,d:i}of e){let e=r(t.r),a=r(n.r),o=typeof e==`number`&&typeof a==`number`?e-a:String(e).localeCompare(String(a),`zh-Hant`);if(o)return o*i}return t.i-n.i})}let it=`${S}|${Pe}|${oe}|${O}`,at=y.useRef(it),ot=nt.length;y.useEffect(()=>{if(it===at.current)return;at.current=``;let e=setTimeout(()=>bi(w(`顯示 {n} 筆`,{n:p_.number(ot)})),400);return()=>clearTimeout(e)},[it,ot]);let st=Math.max(1,Math.ceil(nt.length/r)),ct=Math.min(v,st-1),lt=ct*r,ut=nt.slice(lt,lt+r),dt=e=>{let t=zy(e.r,`id`);return String(t??e.i)},ft=new Set(nt.map(dt)),pt=Object.keys(q).filter(e=>q[e]&&ft.has(e));!Ne&&Object.keys(q).some(e=>q[e]&&!ft.has(e))&&ae(Object.fromEntries(pt.map(e=>[e,!0])));let mt=ut.map(dt),ht=mt.filter(e=>q[e]).length,gt=mt.length>0&&ht===mt.length,_t=ht>0&&!gt,vt=e=>{let t=Ke.current;if(!t)return;let n=t.getBoundingClientRect().top,r={},i=[];for(let e of mt){let t=qe.current[e];t&&(r[e]={top:t.getBoundingClientRect().top-n,bg:getComputedStyle(t).backgroundColor,node:t},i.push(e))}Je.current={kind:e,rows:r,order:i}};y.useLayoutEffect(()=>{let e=Je.current;Je.current=null;let t=Ke.current;if(!e||!t||L()||typeof Element.prototype.animate!=`function`)return;let n=t.getBoundingClientRect().top,r=Math.max(e.order.length,mt.length),i=0,a=48;mt.forEach((t,o)=>{let s=qe.current[t];if(!s)return;let c=s.getBoundingClientRect();a=c.height||a;let l=e.rows[t],u={duration:Ly.dur,delay:o*Ly.stagger,easing:Ly.ease,fill:`backwards`};if(l){let e=l.top-(c.top-n);s.animate([{transform:`translateY(${e}px)`,backgroundColor:l.bg},{transform:`none`,backgroundColor:getComputedStyle(s).backgroundColor}],u)}else{let t=e.kind===`next`?r:e.kind===`prev`?-r:r+i-o;i++,s.animate([{transform:`translateY(${t*a}px)`,opacity:0},{transform:`none`,opacity:1}],u)}}),e.order.forEach((n,i)=>{if(mt.includes(n))return;let o=e.rows[n],s=o.node.cloneNode(!0);s.removeAttribute(`data-rid`),s.setAttribute(`aria-hidden`,`true`),s.classList.add(`ui-dt-ghost`),s.style.top=o.top+`px`,s.style.backgroundColor=o.bg,t.appendChild(s);let c=e.kind===`next`?-r:e.kind===`prev`?r:r+1-i;s.animate([{transform:`none`,opacity:1},{transform:`translateY(${c*a}px)`,opacity:0}],{duration:Ly.dur,easing:Ly.ease,fill:`forwards`}).onfinish=()=>s.remove()})});let yt=e=>{vt(`sort`),_(e),bi(Fy(e,f))},bt=(e,t=!1)=>{if(e.sortable===!1)return;let n=p(e.key),r=n===`asc`?`desc`:`asc`,i=g.findIndex(t=>t.key===e.key);t?i<0?g.length<d?yt([...g,{key:e.key,dir:n}]):bi(w(`最多 {n} 層排序。`,{n:d})):g[i].dir===n?yt(g.map((e,t)=>t===i?{key:e.key,dir:r}:e)):yt(g.filter((e,t)=>t!==i)):g.length!==1||i!==0?yt([{key:e.key,dir:n}]):g[0].dir===n?yt([{key:e.key,dir:r}]):yt([])},xt=e=>{e===ct||e<0||e>=st||(vt(e>ct?`next`:`prev`),x(e))},St=(e,t)=>ae({...q,...Object.fromEntries(e.map(e=>[e,t]))}),Ct=()=>ae({}),wt=y.useRef(null),Tt=`${it}|${Fe}|${r}`;y.useEffect(()=>{wt.current=null},[Tt]);let Et=(e,t,n)=>{let r=nt.map(dt),i=n&&wt.current?r.indexOf(wt.current):-1,a=r.indexOf(e);if(wt.current=e,i<0||a<0||i===a)return St([e],!t);let o={...q,...Object.fromEntries(r.slice(Math.min(i,a),Math.max(i,a)+1).map(e=>[e,!t]))};ae(o),bi(w(`已選 {n} 筆`,{n:r.filter(e=>o[e]).length}))},Dt=()=>{D({}),C(``),x(0)},Ot=!!e.rowActions,kt=ve&&!W,At=Be.some(e=>e.mobile===`title`),jt=(e,t)=>{let n=e.mobile||(!At&&t===0?`title`:null);return n?`is-m-`+n:null},Mt=Be.filter(e=>e.long||e.fullText),Nt=Mt.length>0&&!W&&(J!==!1||Mt.some(e=>e.fullText)||mt.some(e=>V[e])),Pt=(Be.find(e=>!Vy(e)&&!e.long&&e.grow!==0)??Be[0])?.key,Ft=e=>e.grow==null?e.long||e.key===Pt:e.grow>0,It=e=>{if(Ft(e))return Math.max(e.width||(By(e)?96:120),ce[e.key]||0,me&&de[e.key]||0);let t=e.width==null&&!Vy(e),n=t?280:1/0;return Math.max(e.width||0,48,t?128:0,Math.min(ce[e.key]??e.width??96,n))},Lt=e=>({gridTemplateColumns:[Nt?`40px`:null,s?`40px`:null,...Be.map(t=>e?`${e[t.key]??It(t)}px`:Ft(t)?`minmax(${It(t)}px, ${t.grow||1}fr)`:`${It(t)}px`)].filter(Boolean).join(` `),minWidth:(Nt?40:0)+(s?40:0)+Be.reduce((t,n)=>t+(e?e[n.key]??It(n):It(n)),0)}),Rt=Lt(be),zt=Lt(Te),Bt=e=>{let t={};for(let n of Be){let r=e?.querySelector(`.ui-dt-head [data-col="${CSS.escape(n.key)}"]`);t[n.key]=r?Math.ceil(r.getBoundingClientRect().width):It(n)}return t},Vt=(e,t)=>{let n=e?.querySelector(`.ui-dt-head [data-col="${CSS.escape(t)}"] > :first-child`);return Math.max(48,n?Math.ceil(n.getBoundingClientRect().width)+24:48)},Ht=y.useRef(()=>{});y.useLayoutEffect(()=>{let e=K.current;if(!e||W)return;pe.current={};let t=()=>{let t={};for(let n of e.querySelectorAll(`:scope > .ui-dt-scroller .ui-dt-body .ui-dt-cell[data-col]:not(.is-long):not(.is-hug)`)){let e=n.scrollWidth-n.clientWidth,r=n.dataset.col;e>1&&r&&(t[r]=Math.max(t[r]??0,Math.ceil(n.getBoundingClientRect().width+e)))}let n=e=>{let t=getComputedStyle(e);return(parseFloat(t.paddingLeft)||0)+(parseFloat(t.paddingRight)||0)+(parseFloat(t.borderRightWidth)||0)},r=e.querySelectorAll(`:scope > .ui-dt-scroller .ui-dt-cell.is-hug[data-col]`),i=e.querySelectorAll(`:scope > .ui-dt-scroller .ui-dt-cell.is-grow[data-col]`),a={};if(r.length||i.length){e.classList.add(`is-measuring`);for(let e of r){let r=e.dataset.col,i=Uy(e.querySelector(`:scope > .ui-dt-stack > .ui-dt-main`)??e);r&&i!==null&&(t[r]=Math.max(t[r]??0,Math.ceil(i+n(e))))}for(let e of i){let t=e.dataset.col,r=e.querySelector(`.ui-dt-long-text`),i=r?r.getBoundingClientRect().width:Uy(e.querySelector(`:scope > .ui-dt-stack > .ui-dt-main`)??e);if(!t||i===null||!i)continue;let o=e.classList.contains(`is-long`)?512:320;a[t]=Math.max(a[t]??0,Math.min(o,Math.ceil(i+n(e))))}e.classList.remove(`is-measuring`)}le(e=>{let n=Object.entries(t).filter(([t,n])=>n>(e[t]??0));return n.length?{...e,...Object.fromEntries(n)}:e});let o=e.querySelector(`:scope > .ui-dt-scroller .ui-dt-head`),s=e.querySelector(`:scope > .ui-dt-scroller .ui-dt-scroll`);if(o&&s&&s.clientWidth>0){let e=pe.current,t=Object.entries(a).filter(([t,n])=>n>(e[t]??0)),n=t.length?{...e,...Object.fromEntries(t)}:e;pe.current=n,t.length&&fe(n);let r=0;for(let e of o.children){if(e.classList.contains(`ui-dt-exp`))continue;let t=e.dataset.col;r+=t&&e.classList.contains(`is-grow`)?Math.max(a[t]??0,n[t]??0,48):e.getBoundingClientRect().width}he(r<=s.clientWidth)}let c=0;for(let t of e.querySelectorAll(`:scope > .ui-dt-scroller .ui-dt-body .ui-dt-acts`))t.childElementCount&&(c=Math.max(c,Math.ceil(t.getBoundingClientRect().width)));e.querySelector(`:scope > .ui-dt-scroller .ui-dt-body .ui-dt-acts`)&&_e(e=>e!==null&&Math.abs(e-c)<=1?e:c);let l=e.querySelector(`:scope > .ui-dt-tools.has-summary`);if(l&&l.clientWidth>0){let e=l.querySelector(`.ui-dt-summary`),t=l.querySelector(`:scope > .ui-dt-actions`),n=(e?.scrollWidth??0)+(l.querySelector(`:scope > .ui-dt-search`)?256:8),r=t?[...t.children].filter(e=>getComputedStyle(e).position!==`absolute`):[];for(let e of r){let t=e.querySelector(`.ui-dt-sortbtn-text`);n+=e.getBoundingClientRect().width+(t?Math.max(0,t.scrollWidth-t.clientWidth):0)}n+=Math.max(0,r.length-1)*8,ye(n<=l.clientWidth)}let u=e.querySelector(`:scope > .ui-dt-scroller .ui-dt-scroll`);if(u&&u.clientWidth>0){let t=[...e.querySelectorAll(`:scope > .ui-dt-scroller .ui-dt-body .ui-dt-long`)].some(e=>e.scrollWidth>e.clientWidth+1);ue(t)}},n=0,r=()=>{n||=requestAnimationFrame(()=>{n=0,t()})};Ht.current=r,t();let i=new MutationObserver(r);for(let t of e.querySelectorAll(`:scope > .ui-dt-scroller .ui-dt-table, :scope > .ui-dt-scroller .ui-dt-body`))i.observe(t,{childList:!0});document.fonts?.ready.then(r).catch(()=>{});let a=-1,o=U(e=>{let t=Math.round(e[0]?.contentRect.width??0);t!==a&&a>=0&&r(),a=t});return o?.observe(e),()=>{i.disconnect(),o?.disconnect(),cancelAnimationFrame(n),Ht.current=()=>{}}},[W,je]),y.useLayoutEffect(()=>{Ht.current()},[ge]);let Ut=`${mt.join(``)}|${Be.map(e=>e.key).join(`,`)}|${nt.length}|${S}|${!!e.totals}`;y.useLayoutEffect(()=>{Ht.current()},[Ut,n]);let Wt=e=>e===0&&c?{left:(Nt?40:0)+(s?40:0)}:void 0,Gt=(e,t,...n)=>M(`ui-dt-cell`,By(e)&&`is-num`,Ft(e)?`is-grow`:`is-hug`,t===0&&c&&`is-sticky is-sticky-end`,t===Be.length-1&&`is-lastcol`,...n),Kt=e=>c?{className:`is-sticky`,style:{left:e===`sel`&&Nt?40:0}}:{className:void 0,style:void 0},qt=t=>{let n=t?zt:Rt,r=n.minWidth,i=t?Te:be,a=t?Ee:Se,o=()=>t?De.current:K.current;return s&&pt.length&&e.bulkActions?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-row ui-dt-head ui-dt-bulk`,role:`row`,style:{minWidth:r},children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dt-cell`,role:`columnheader`,children:/* @__PURE__ */ (0,A.jsx)(tb,{v:gt?!0:`mixed`,label:w(`全選`),onClick:()=>St(mt,!gt)})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-bulk-count`,children:w(`已選 {n} 筆`,{n:pt.length})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-bulk-actions`,children:e.bulkActions(pt,Ct)}),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-dt-bulk-close`,"aria-label":w(`取消選取`),onClick:Ct,children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`,size:14})})]}):/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-row ui-dt-head`,role:`row`,style:n,children:[Nt?/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-dt-cell ui-dt-exp`,Kt(`exp`).className),style:Kt(`exp`).style,role:`columnheader`,"aria-label":w(`詳細`)}):null,s?/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-dt-cell ui-dt-sel`,Kt(`sel`).className),style:Kt(`sel`).style,role:`columnheader`,children:/* @__PURE__ */ (0,A.jsx)(tb,{v:gt?!0:_t?`mixed`:!1,label:w(`全選`),onClick:()=>St(mt,!gt)})}):null,Be.map((e,t)=>{let n=g.findIndex(t=>t.key===e.key),r=n>=0,s=g.length>1;return/* @__PURE__ */ (0,A.jsxs)(`div`,{role:`columnheader`,"aria-sort":n===0?g[0].dir===`asc`?`ascending`:`descending`:`none`,className:Gt(e,t),style:Wt(t),"data-col":e.key,children:[e.sortable===!1?e.label:/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-dt-sort`,r&&`is-on`),"aria-label":r&&s?w(`{name},第 {n} 排序,{dir}`,{name:e.label,n:n+1,dir:Ny(g[n].dir)}):void 0,"aria-keyshortcuts":`Shift+Enter`,onClick:t=>bt(e,t.shiftKey),onKeyDown:t=>{t.shiftKey&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),bt(e,!0))},children:[/* @__PURE__ */ (0,A.jsx)(`span`,{children:e.label}),/* @__PURE__ */ (0,A.jsx)(Y,{d:Ry[r?g[n].dir:`none`],size:14,className:`ui-dt-arrow`}),r&&s?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-sortpri`,"aria-hidden":`true`,children:n+1}):null]}),W?null:/* @__PURE__ */ (0,A.jsx)(cy,{name:e.label,width:i?.[e.key]??It(e),start:()=>(i??Bt(o()))[e.key]??It(e),onWidth:t=>a({...i??Bt(o()),[e.key]:Math.max(Vt(o(),e.key),t)}),onReset:()=>a(null)})]},e.key)})]})},Jt=et?S:``,Yt=(e,t)=>{if(t.format!==`relative`||t.render)return``;let n=gy(zy(e,t.key)),r=n?p_.dateTime(n):``;return r&&r!==p_.relative(n)?r:``},Xt=(e,t)=>{let n=zy(e,t.key),r;if(t.render)r=t.render(e);else if(hy(t)&&gy(n)){let i=gy(n),a=Yt(e,t),o=/* @__PURE__ */ (0,A.jsx)(`time`,{className:`ui-dt-time`,dateTime:Hy(i,t.format===`date`),children:Dy(py(t,n),Jt)});r=a?/* @__PURE__ */ (0,A.jsx)(Zf,{label:a,describe:!1,disabled:re,children:o}):o}else r=t.unit&&n!=null&&n!==``?/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-dt-qty`,children:[Dy(py({...t,unit:void 0},n),Jt),` `,/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-unit`,children:t.unit})]}):n==null||n===``?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-none`,children:py(t,n)}):Dy(py(t,n),Jt);return r},Zt=e=>{let t=e.target.closest(eb);if(t&&t!==e.currentTarget)return!1;let n=window.getSelection();return!(n&&!n.isCollapsed&&String(n).trim())},Qt=(t,n)=>{let r=e.rowHref?.(t);r!=null&&($y(n)?(n.preventDefault(),window.open(r,`_blank`,`noopener`)):e.onRowOpen?e.onRowOpen(t,n):n.currentTarget.querySelector(`a.ui-dt-rowlink`)?.click())},$t=(t,n,r)=>{let i=n.long?/* @__PURE__ */ (0,A.jsx)(My,{children:Xt(t,n)}):Xt(t,n);n.fullText&&(i=/* @__PURE__ */ (0,A.jsx)(jy,{text:n.fullText(t),children:i})),r===0&&e.rowHref&&(i=/* @__PURE__ */ (0,A.jsx)(`a`,{className:`ui-dt-rowlink`,href:e.rowHref(t),onClick:e.onRowOpen?n=>{$y(n)||(n.preventDefault(),e.onRowOpen?.(t,n))}:void 0,children:i}));let a=n.secondary?.(t);return a==null||a===``||a===!1?i:/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-dt-stack`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-main`,children:i}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-sub`,children:a})]})},en=(t,n)=>{let r=e.totals?.[t.key],i=nt.map(e=>e.r);if(n===0&&!r)return/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-qty`,children:F(w(`合計 {n} 筆`,{n:``}),[p_.number(i.length)])});if(typeof r==`function`)return r(i);if(r===`sum`||r===`avg`){let e=i.reduce((e,n)=>e+(Number(zy(n,t.key))||0),0),n=r===`sum`?e:e/(i.length||1),a=py({...r===`avg`&&!t.format?{...t,decimals:1}:t,unit:void 0},n);return/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-dt-qty`,children:[r===`avg`?/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-unit`,children:[w(`平均`),` `]}):null,a,t.unit?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[` `,/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-unit`,children:t.unit})]}):null]})}return``},tn=()=>{let t=nt.map(e=>e.r);return e.copyText?e.copyText(t):dy(Be.map(e=>e.label),t.map(e=>Be.map(t=>String(t.fullText?.(e)??t.searchText?.(e)??py(t,zy(e,t.key))??``))))},[nn,rn]=y.useState(!1),an=y.useRef(void 0);y.useEffect(()=>()=>clearTimeout(an.current),[]);let on=()=>te(tn()).then(()=>{rn(!0),bi(w(`已複製`)),clearTimeout(an.current),an.current=setTimeout(()=>rn(!1),2e3)},()=>e.onCopyError?.()),sn=o!==!1&&e.searchShortcut!==!1,[cn,ln]=y.useState(!1);y.useEffect(()=>{let e=K.current;if(!sn||!e)return;let t=Qy(e,()=>ln(Xy()===e));return()=>{t(),ln(!1)}},[sn]);let[un,dn]=y.useState(!1),fn=(e,t)=>{D(t===void 0?Object.fromEntries(Object.entries(E).filter(([t])=>t!==e)):{...E,[e]:t}),x(0)},pn=[];for(let e of l){let t=E[e.key];if(t&&yy(t)){if(Array.isArray(t))for(let n of t)pn.push({id:e.key+`=`+n,text:w(`{name}:{value}`,{name:e.label,value:e.options.find(e=>String(e.value)===n)?.label??n}),remove:()=>fn(e.key,t.filter(e=>e!==n))});else{let n=t.min&&t.max?`${t.min}–${t.max}`:t.min?`≥ ${t.min}`:`≤ ${t.max}`;pn.push({id:e.key,text:w(`{name}:{value}`,{name:e.label,value:n}),remove:()=>fn(e.key,void 0)})}}}let mn=e=>/* @__PURE__ */ (0,A.jsx)(ky,{chips:pn,onClear:()=>{D({}),x(0)},filterButton:()=>(e?De:K).current?.querySelector(`.ui-dt-filterbtn`)??null}),hn=Qe?/* @__PURE__ */ (0,A.jsx)(ay,{className:`ui-dt-summary`,label:Qe.label||w(`依狀態篩選`),unit:Qe.unit||`筆`,value:oe,onChange:e=>{vt(`sort`),se(e),x(0)},items:[{id:`all`,label:w(`全部`),count:Ze.length},...Qe.items.map(e=>({id:String(e.value),label:e.label,count:Ze.filter(t=>String(zy(t.r,Qe.key))===String(e.value)).length}))],hideUnit:!0}):null,gn=!Qe||nt.length!==$e,_n=(n,r=!1)=>/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-dt-tools`,r&&`is-inhead`,hn&&!n&&!r&&`has-summary`,kt&&!n&&!r&&`is-onerow`),children:[hn&&!n&&!r?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dt-sumwrap`,children:hn}):null,o===!1&&e.caption&&!n&&!r?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dt-caption`,children:e.caption}):null,o===!1?null:/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-search`,onFocus:()=>dn(!0),onBlur:()=>dn(!1),children:[/* @__PURE__ */ (0,A.jsx)(iy,{value:S,onChange:e=>{C(e),x(0)},placeholder:o.placeholder||w(`搜尋`),label:o.placeholder||w(`搜尋`),"aria-keyshortcuts":cn&&!n?`/`:void 0,className:`ui-dt-searchfield`}),cn&&!n&&!W&&!S&&!un?/* @__PURE__ */ (0,A.jsx)(`kbd`,{className:`ui-dt-kbd`,"aria-hidden":`true`,children:`/`}):null]}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-actions`,children:[l.length?/* @__PURE__ */ (0,A.jsx)(Ay,{boundary:n?De:K,filters:l,values:E,activeCount:rt,count:(e,t)=>Ye.filter(n=>tt(n.r,e.key)&&by(e,n.r,e.type===`list`?[t]:void 0)).length,onChange:(e,t)=>fn(e,t),onClear:()=>{D({}),x(0)}}):null,/* @__PURE__ */ (0,A.jsxs)(`span`,{className:M(`ui-dt-result`,!gn&&`ui-visually-hidden`),children:[/* @__PURE__ */ (0,A.jsx)(`span`,{"aria-hidden":`true`,children:N(w(`{n} / {total} 筆`,{n:``,total:``}),[p_.number(nt.length),p_.number($e)])}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:p_.fractionLabel(nt.length,$e,w(`筆`))})]}),f.length?/* @__PURE__ */ (0,A.jsx)(Iy,{cols:f,levels:g,max:d,onChange:yt,boundary:n?De:K}):null,W?null:/* @__PURE__ */ (0,A.jsx)(Oy,{columns:e.columnMenu!==!1&&t.length>2?{cols:t,hidden:ze,onToggle:e=>z({...I,[e]:!ze[e]}),onReset:()=>{z({}),Se(null),Ee(null),bi(w(`已還原預設的欄位與欄寬`))}}:void 0,onCopy:e.copy===!1?void 0:on,onZoom:e.zoom!==!1&&!n?()=>we(!0):void 0}),e.action&&!n?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dt-primary`,children:e.action}):null,nn&&!W?/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-dt-copied`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`check`,size:16}),w(`已複製`)]}):null]})]}),vn=t=>{let n=t?zt:Rt,r=t?ie+`z`:ie;return/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-dt-scroller`,He&&!t&&`has-more`),children:/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-dt-scroll`,st>1&&`is-paged`),ref:t?void 0:Ve,onScroll:t?void 0:Ge,children:/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-table`,role:`table`,"aria-label":e.label||e.caption,children:[qt(t),/* @__PURE__ */ (0,A.jsx)(`div`,{ref:t?void 0:Ke,className:`ui-dt-body`,role:`rowgroup`,children:ut.length?ut.map((i,a)=>{let o=mt[a],c=!!q[o],l=Nt&&!!V[o],u=`${r}-d-${j(o)}`,d=Be[0]?String(py(Be[0],zy(i.r,Be[0].key))??``):``;return/* @__PURE__ */ (0,A.jsxs)(y.Fragment,{children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{"data-rid":o,ref:t?void 0:e=>{qe.current[o]=e},role:`row`,"aria-labelledby":Be.length?`${r}-n-${lt+a}`:void 0,className:M(`ui-dt-row`,a%2&&`is-even`,Ot&&`has-acts`,c&&`is-selected`,s&&`has-sel`,Nt&&!e.rowHref&&`has-exp`,e.rowHref&&`has-href`),style:n,onClick:Nt||e.rowHref?t=>{if(Zt(t)){if(e.rowHref)return Qt(i.r,t);ne({...V,[o]:!l})}}:void 0,onMouseDown:e.rowHref?e=>{(e.shiftKey||e.button===1)&&!e.target.closest(eb)&&e.preventDefault()}:void 0,onAuxClick:e.rowHref?e=>{e.button===1&&Zt(e)&&Qt(i.r,e)}:void 0,children:[Nt?/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-dt-cell ui-dt-exp`,Kt(`exp`).className),style:Kt(`exp`).style,role:`cell`,children:/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:M(`ui-dt-exp-btn`,l&&`is-open`),"aria-expanded":l,"aria-controls":l?u:void 0,"aria-label":w(l?`收合 {name}`:`展開 {name}`,{name:d}),onClick:()=>ne({...V,[o]:!l}),children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-right`,size:16})})}):null,s?/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-dt-cell ui-dt-sel`,Kt(`sel`).className),style:Kt(`sel`).style,role:`cell`,children:/* @__PURE__ */ (0,A.jsx)(tb,{v:c,label:w(`選取第 {n} 筆`,{n:lt+a+1}),onClick:e=>Et(o,c,e.shiftKey)})}):null,Be.map((e,t)=>/* @__PURE__ */ (0,A.jsx)(`div`,{role:`cell`,id:t===0?`${r}-n-${lt+a}`:void 0,"aria-description":[e.fullText?.(i.r),Yt(i.r,e)].filter(Boolean).join(`,`)||void 0,"data-label":e.label,"data-col":e.key,className:Gt(e,t,e.long&&`is-long`,jt(e,t)),style:Wt(t),children:$t(i.r,e,t)},e.key)),Ot?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dt-cell ui-dt-acts`,role:`cell`,children:e.rowActions?.(i.r)}):null]}),l?/* @__PURE__ */ (0,A.jsx)(`div`,{id:u,role:`row`,className:M(`ui-dt-detail`,a%2&&`is-even`),style:{minWidth:n.minWidth},children:/* @__PURE__ */ (0,A.jsx)(`div`,{role:`cell`,className:`ui-dt-detail-cell`,style:{paddingLeft:40+(s?40:0)+12},children:Mt.map(e=>/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-detail-item`,children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dt-detail-label`,children:e.label}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dt-detail-text`,children:e.fullText?e.fullText(i.r):Xt(i.r,e)})]},e.key))})}):null]},o)}):/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-empty`,children:[e.emptyText||w(`沒有符合的資料`),S||rt?/* @__PURE__ */ (0,A.jsx)(`div`,{children:/* @__PURE__ */ (0,A.jsx)(Xp,{onClick:Dt,children:w(`清除篩選`)})}):null]})}),e.totals&&nt.length?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-row ui-dt-total`,role:`row`,style:n,children:[Nt?/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-dt-cell ui-dt-exp`,Kt(`exp`).className),style:Kt(`exp`).style,role:`cell`}):null,s?/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-dt-cell ui-dt-sel`,Kt(`sel`).className),style:Kt(`sel`).style,role:`cell`}):null,Be.map((t,n)=>/* @__PURE__ */ (0,A.jsx)(`div`,{role:`cell`,className:Gt(t,n),style:Wt(n),"data-col":t.key,"data-label":n>0&&e.totals?.[t.key]?t.label:void 0,children:en(t,n)},t.key))]}):null]})})})},yn=/* @__PURE__ */ (0,A.jsx)(A.Fragment,{children:st>1?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dt-foot`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dt-range`,children:F(w(`第 {a}–{b} 筆,共 {n} 筆`,{a:``,b:``,n:``}),[lt+1,Math.min(nt.length,lt+r),p_.number(nt.length)])}),/* @__PURE__ */ (0,A.jsxs)(`nav`,{className:`ui-dt-pages`,"aria-label":w(`分頁`),children:[/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-dt-page`,"aria-label":w(`上一頁`),disabled:ct===0,onClick:()=>xt(ct-1),children:`‹`}),Array.from({length:st},(e,t)=>/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:M(`ui-dt-page`,t===ct&&`is-on`),"aria-current":t===ct?`page`:void 0,onClick:()=>xt(t),children:String(t+1)},t)),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-dt-page`,"aria-label":w(`下一頁`),disabled:ct>=st-1,onClick:()=>xt(ct+1),children:`›`})]})]}):null});return/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:K,className:M(`ui-dt`,o===!1&&`is-nosearch`,pt.length&&`has-sel`,Ot&&`has-acts`,e.className),style:Ot?{"--dt-acts-w":(e.actionsWidth??ge??72)+`px`}:void 0,children:[e.caption&&o!==!1?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dt-caption`,children:e.caption}):null,e.views?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dt-views`,role:`tablist`,"aria-label":w(`檢視`),children:e.views.map(e=>{let t=e.id===O,r=n.filter(t=>!e.filter||e.filter(t)).length;return/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,className:M(`ui-dt-view`,t&&`is-on`),onClick:()=>{k(e.id),x(0)},children:[e.label,` `,/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-dt-view-n`,children:[p_.number(r),/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-visually-hidden`,children:[` `,T(`筆`,r)]})]})]},e.id)})}):null,hn&&Oe?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-dt-top`,children:hn}):null,Oe?(0,b.createPortal)(_n(!1,!0),Oe):_n(!1),mn(!1),vn(!1),/* @__PURE__ */ (0,A.jsx)(sy,{show:Ue,done:We}),yn,/* @__PURE__ */ (0,A.jsx)(uy,{open:Ce,onClose:()=>we(!1),title:e.caption||e.label,children:/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:De,className:`ui-dt ui-dt-zoomed`,children:[_n(!0),mn(!0),vn(!0),yn]})})]})}ke(),ti(Oe);function rb({label:e,value:t,onChange:n,hint:r,required:i,error:a,className:o}){let s=y.useId(),[c,l]=y.useState(!1),[u,d]=y.useState(null),f=y.useRef(null),p=u!==null&&u!==``&&!h_(u),[m,h]=y.useState(!1),g=p&&m?w(`日期格式不正確,請寫成 2026/11/14`):a,_=s+`-msg`,v=e=>{d(null),h(!1),n(e),l(!1)};return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-field`,g&&`has-error`,o),children:[e?/* @__PURE__ */ (0,A.jsx)(N_,{htmlFor:s,required:i,children:e}):null,/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:f,className:M(`ui-datefield`,g&&`is-invalid`),children:[/* @__PURE__ */ (0,A.jsx)(`input`,{id:s,className:`ui-datefield-input`,value:u??m_(t),placeholder:`YYYY/MM/DD`,"aria-required":i||void 0,"aria-invalid":g?!0:void 0,"aria-describedby":_,onChange:e=>{let t=e.target.value;d(t);let r=h_(t);r?n(r):t===``&&n(null)},onBlur:()=>p?h(!0):d(null)}),g?/* @__PURE__ */ (0,A.jsx)(F_,{inline:!0}):null,/* @__PURE__ */ (0,A.jsxs)(wv,{open:c,onOpenChange:l,anchor:f,className:`ui-datepop`,"aria-label":w(`選擇日期`),trigger:/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-datefield-btn`,"aria-label":w(`開啟日曆`),children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`calendar-blank`,size:18})}),children:[/* @__PURE__ */ (0,A.jsx)(A_,{focus:t,dayState:e=>({selected:g_(e,t)}),onPick:v}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-datepop-foot`,children:[/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn`,onClick:()=>v(new Date((/* @__PURE__ */ new Date()).setHours(0,0,0,0))),children:w(`今天`)}),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn is-muted`,onClick:()=>v(null),children:w(`清除`)})]})]})]}),/* @__PURE__ */ (0,A.jsx)(I_,{id:_,error:g,hint:r||w(`可以直接輸入,例如 2026/11/14`)})]})}ke(),ti(Oe);let ib=e=>p_.date(e,{weekday:!1});function ab({label:e,value:t,onChange:n,placeholder:r,className:i}){let[a,o]=y.useState(!1),[s,c]=y.useState(null),[l,u]=y.useState(null),d=/* @__PURE__ */ new Date;d.setHours(0,0,0,0);let f=[[w(`今天`),[d,d]],[w(`最近 7 天`),[__(d,-6),d]],[w(`最近 30 天`),[__(d,-29),d]],[w(`本月`),[new Date(d.getFullYear(),d.getMonth(),1),new Date(d.getFullYear(),d.getMonth()+1,0)]],[w(`上個月`),[new Date(d.getFullYear(),d.getMonth()-1,1),new Date(d.getFullYear(),d.getMonth(),0)]]],p=e=>{o(e),e||c(null)},m=e=>{n(e),p(!1)},h=s||t[0],g=s?l||s:t[1],_=h&&g&&g<h?g:h,v=h&&g&&g<h?h:g;return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-field`,i),children:[e?/* @__PURE__ */ (0,A.jsx)(N_,{children:e}):null,/* @__PURE__ */ (0,A.jsxs)(wv,{open:a,onOpenChange:p,className:`ui-datepop ui-rangepop`,"aria-label":w(`選擇期間`),trigger:/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-datefield`,`ui-rangefield`,a&&`is-open`),"aria-label":t[0]?w(`{label}:{a} 到 {b}`,{label:e||w(`期間`),a:ib(t[0]),b:ib(t[1])}):`${e||w(`期間`)}${w(`:`)}${r||w(`選擇期間`)}`,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`calendar-blank`,size:18}),/* @__PURE__ */ (0,A.jsx)(`span`,{children:t[0]?`${ib(t[0])} – ${ib(t[1])}`:r||w(`選擇期間`)})]}),children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-quick`,children:f.map(([e,n])=>/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:M(`ui-quick-btn`,g_(n[0],t[0])&&g_(n[1],t[1])&&`is-on`),onClick:()=>m(n),children:e},e))}),/* @__PURE__ */ (0,A.jsx)(A_,{focus:t[1]||t[0],onHover:s?u:void 0,dayState:e=>({selected:g_(e,_)||g_(e,v),start:g_(e,_),end:g_(e,v),inRange:!!_&&!!v&&e>_&&e<v}),onPick:e=>{s?m(s<=e?[s,e]:[e,s]):(c(e),u(e))}})]})]})}function ob({items:e,labelWidth:t,labelSize:n,className:r}){return/* @__PURE__ */ (0,A.jsx)(`dl`,{className:M(`ui-dl`,t===`auto`&&`is-auto`,typeof t==`number`&&`is-fixed`,n===`body`&&`is-body`,r),style:typeof t==`number`?{"--dl-label":t+`px`}:void 0,children:e.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-dl-item`,children:[/* @__PURE__ */ (0,A.jsx)(`dt`,{children:e.label}),/* @__PURE__ */ (0,A.jsx)(`dd`,{children:e.value})]},t))})}let sb=e=>{if(!e)return null;try{let t=Number(window.localStorage.getItem(`ui-split:`+e));return Number.isFinite(t)&&t>0?t:null}catch{return null}},cb=(e,t)=>{if(e)try{window.localStorage.setItem(`ui-split:`+e,String(Math.round(t)))}catch{}};function lb({a:e,b:t,defaultB:n=420,minA:r=360,minB:i=280,storageKey:a,label:o,onResize:s,className:c}){G(n<i,`SplitPane`,`defaultB (${n} px) is under minB (${i} px): the panel starts at ${i} px. Raise defaultB or lower minB.`);let l=y.useRef(null),[u,d]=y.useState(0),[f,p]=y.useState(()=>(typeof window>`u`?null:sb(a))??n),[m,h]=y.useState(!1),g=y.useRef(!1),_=y.useId();y.useLayoutEffect(()=>{let e=l.current;if(!e)return;let t=()=>d(e.clientWidth);t();let n=U(t);return n?.observe(e),()=>n?.disconnect()},[]);let v=u>0&&u<960,b=Math.max(i,u-16-r),x=Math.round(Math.min(b,Math.max(i,f))),S=Math.max(0,u-16-x),C=y.useRef(x),T=(e,t=!0)=>{let n=Math.round(Math.min(b,Math.max(i,e)));C.current=n,p(n),t&&cb(a,n),s?.(n)},E=e=>{if(W(e))return;let t=e.key===`ArrowLeft`?x+16:e.key===`ArrowRight`?x-16:e.key===`Home`?b:e.key===`End`?i:e.key===`Enter`?n:null;t!=null&&(e.preventDefault(),T(t))},D=e=>{if(e.button===0){e.preventDefault();try{e.currentTarget.setPointerCapture?.(e.pointerId)}catch{}e.currentTarget.focus({preventScroll:!0}),g.current=!0,h(!0)}},O=e=>{if(!g.current||!l.current)return;let t=l.current.getBoundingClientRect();T(t.right-e.clientX-8,!1)},k=e=>{if(g.current){g.current=!1,h(!1);try{e.currentTarget.hasPointerCapture?.(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)}catch{}l.current&&cb(a,C.current)}};return/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:l,className:M(`ui-split`,v&&`is-stacked`,m&&`is-dragging`,c),style:v||!u?void 0:{gridTemplateColumns:`minmax(0, 1fr) 16px ${x}px`},children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-split-a`,children:e}),v?null:/* @__PURE__ */ (0,A.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":o||w(`調整面板寬度`),"aria-controls":_,"aria-valuenow":S,"aria-valuemin":r,"aria-valuemax":Math.max(r,u-16-i),"aria-valuetext":w(`主要區域 {a} px,面板 {b} px`,{a:S,b:x}),className:`ui-split-handle`,onKeyDown:E,onPointerDown:D,onPointerMove:O,onPointerUp:k,onPointerCancel:k,onDoubleClick:()=>T(n),children:/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-split-grip`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsx)(`i`,{}),/* @__PURE__ */ (0,A.jsx)(`i`,{}),/* @__PURE__ */ (0,A.jsx)(`i`,{})]})}),/* @__PURE__ */ (0,A.jsx)(`div`,{id:_,className:`ui-split-b`,children:t})]})}function ub({title:e,description:t,steps:n=[],current:r=0,action:i}){return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-empty`,children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-empty-title`,children:e}),t?/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-empty-desc`,children:im(t)}):null,n.length?/* @__PURE__ */ (0,A.jsx)(`ol`,{className:`ui-steps`,children:n.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`li`,{className:t===r?`is-current`:void 0,"aria-current":t===r?`step`:void 0,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-step-num`,children:t+1}),/* @__PURE__ */ (0,A.jsx)(`span`,{children:im(e)})]},t))}):null,i??null]})}let db={404:[`找不到這個頁面`,`網址可能打錯了,或這個頁面已經移除。`],500:[`伺服器暫時無法回應`,`這個問題已經記錄下來,請稍後重新整理再試。`],403:[`沒有權限查看這個頁面`,`請向管理員申請權限,或切換成有權限的帳號。`]};function fb({code:e,title:t,description:n,onBack:r,onHome:i,homeHref:a=`/`,className:o}){let s=db[e];return/* @__PURE__ */ (0,A.jsxs)(`main`,{className:M(`ui-errorpage`,o),children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-errorpage-code`,"aria-hidden":`true`,children:e}),/* @__PURE__ */ (0,A.jsx)(`h1`,{className:`ui-errorpage-title`,children:t||w(s?s[0]:`發生錯誤`)}),/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-errorpage-desc`,children:im(n||(s?w(s[1]):``))}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-errorpage-actions`,children:[/* @__PURE__ */ (0,A.jsx)(Xp,{onClick:r??(()=>history.back()),children:w(`回上一頁`)}),/* @__PURE__ */ (0,A.jsx)(Xp,{variant:`primary`,onClick:i??(()=>location.href=a),children:w(`回首頁`)})]})]})}function pb({value:e,label:t,className:n,...r}){let i=Math.max(0,Math.min(100,e||0)),a=i>=100;return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-progress`,a&&`is-done`,n),children:[t?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-field-label`,children:t}):null,/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-progress-track`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(i),"aria-label":t||r[`aria-label`],children:/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-progress-fill`,style:{width:i+`%`}})}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-progress-text`,children:a?w(`完成 ✓`):Math.round(i)+`%`})]})}xt(),Jn(),ir(),ti(bt,qn,rr);function mb({label:e,files:t=[],onAdd:n,onRemove:r,onRetry:i,limitText:a,accept:o,multiple:s=!0,className:c}){let[l,u]=y.useState(!1),d=y.useRef(null),f=e=>{let t=Array.from(e??[]);t.length&&n?.(t)};return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-upload`,c),children:[e?/* @__PURE__ */ (0,A.jsx)(N_,{children:e}):null,/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-dropline`,l&&`is-drag`),onDragOver:e=>{e.preventDefault(),u(!0)},onDragLeave:()=>u(!1),onDrop:e=>{e.preventDefault(),u(!1),f(e.dataTransfer.files)},children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`upload-simple`,size:18}),/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-dropline-text`,children:[w(`拖放檔案,或 `),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn`,onClick:()=>d.current?.click(),children:w(`選擇檔案`)})]}),a?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-dropline-limit`,children:a}):null,/* @__PURE__ */ (0,A.jsx)(`input`,{ref:d,type:`file`,multiple:s,accept:o,hidden:!0,onChange:e=>{f(e.target.files),e.target.value=``}})]}),t.length?/* @__PURE__ */ (0,A.jsx)(`ul`,{className:`ui-upload-list`,children:t.map(e=>{let t=e.status===`error`;return/* @__PURE__ */ (0,A.jsxs)(`li`,{className:M(`ui-upload-item`,t&&`is-error`),children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`file`,size:20,className:`ui-upload-icon`}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-upload-body`,children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-upload-row`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-upload-name`,children:e.name}),e.size?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-upload-size`,children:e.size}):null]}),t?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-upload-error`,role:`alert`,children:[im(e.error||w(`上傳失敗,請再試一次。`)),i?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn`,onClick:()=>i(e),children:w(`重試`)}):null]}):/* @__PURE__ */ (0,A.jsx)(pb,{value:e.status===`done`?100:e.progress||0,"aria-label":w(`{name} 上傳進度`,{name:e.name})})]}),r?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-dialog-close`,"aria-label":w(`移除 {name}`,{name:e.name}),onClick:()=>r(e),children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`,size:16})}):null]},e.id??e.name)})}):null]})}function hb({children:e,className:t}){return/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-formgrid`,t),children:e})}function gb(){let e=(e,t)=>/* @__PURE__ */ (0,A.jsx)(`marker`,{id:e,viewBox:`0 0 10 10`,refX:9,refY:5,markerWidth:7,markerHeight:7,orient:`auto-start-reverse`,children:/* @__PURE__ */ (0,A.jsx)(`path`,{d:`M0 0L10 5L0 10z`,className:M(`ui-graph-arrow`,t&&`is-accent`)})});return/* @__PURE__ */ (0,A.jsxs)(`defs`,{children:[e(`ui-arrow`,!1),e(`ui-arrow-accent`,!0)]})}let _b=[{type:`edge`,label:`確定的關係`},{type:`inferred`,label:`推測的關係`},{type:`external`,label:`外部項目`}];function vb({type:e}){return e===`weight`?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-graph-legend-sw`,children:[1.5,6].map(e=>/* @__PURE__ */ (0,A.jsx)(`svg`,{width:22,height:8,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(`line`,{x1:0,y1:4,x2:22,y2:4,className:`ui-graph-edge`,style:{strokeWidth:e}})},e))}):e===`external`||e===`node`?/* @__PURE__ */ (0,A.jsx)(`svg`,{width:22,height:14,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(`rect`,{x:1,y:1,width:20,height:12,rx:4,className:M(`ui-graph-node`,e===`external`&&`is-external`)})}):/* @__PURE__ */ (0,A.jsx)(`svg`,{width:28,height:8,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(`line`,{x1:0,y1:4,x2:28,y2:4,className:M(`ui-graph-edge`,e===`inferred`&&`is-inferred`,e===`declared`&&`is-declared`)})})}function yb({items:e=_b,className:t}){return/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-graph-legend`,t),children:e.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-graph-legend-item`,children:[/* @__PURE__ */ (0,A.jsx)(vb,{type:e.type}),e.text?/* @__PURE__ */ (0,A.jsx)(Tv,{title:e.label,text:e.text,children:w(e.label)}):w(e.label)]},t))})}function bb({text:e,label:t,className:n}){let r=e??w(`AI 撰寫`);return/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-aimark`,n),"aria-hidden":`true`,children:r}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:t??w(`({v})`,{v:r})})]})}Fe(),ti(Pe);let xb=/^\s*<details\b[^>]*>/i,Sb=/<(\/?)details\b[^>]*>/gi,Cb=/<summary\b[^>]*>([\s\S]*?)<\/summary>/i,wb=/^\s*\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*$/i,Tb={NOTE:`info`,TIP:`success`,IMPORTANT:`info`,WARNING:`warning`,CAUTION:`danger`},Eb=/^ {0,3}(`{3,}|~{3,})\s*([\w+#.-]*)/,Db=/^ {0,3}(#{1,6})(?:\s+(.*?))?\s*#*\s*$/,Ob=/^ {0,3}([-*_])(?:\s*\1){2,}\s*$/,kb=/^( {0,3})([-*+]|\d{1,9}[.)])(\s+|$)(.*)$/,Ab=/^ {0,3}> ?(.*)$/,jb=/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/;function Mb(e){let t=e.trim();t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&!t.endsWith(`\\|`)&&(t=t.slice(0,-1));let n=[],r=``,i=!1;for(let e=0;e<t.length;e++){let a=t[e];a===`\\`&&t[e+1]===`|`?(r+=`|`,e++):a==="`"?(i=!i,r+=a):a===`|`&&!i?(n.push(r.trim()),r=``):r+=a}return n.push(r.trim()),n}let Nb=e=>!e.trim(),Pb=e=>Eb.test(e)||Db.test(e)||Ob.test(e)||Ab.test(e)||kb.test(e);function Fb(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(Nb(r)){n++;continue}if(xb.test(r)){let r=e.slice(n).join(`
83
+ `);Sb.lastIndex=0;let i=0,a=-1,o=r.length,s=r.length;for(let e=Sb.exec(r);e;e=Sb.exec(r))if(!e[1])i++===0&&(a=e.index+e[0].length);else if(--i===0){o=e.index,s=e.index+e[0].length;break}let c=r.slice(a,o),l=Cb.exec(c);return l&&(c=c.slice(0,l.index)+c.slice(l.index+l[0].length)),t.push({t:`details`,summary:(l?.[1]??``).trim(),blocks:Fb(c.split(`
84
+ `))}),t.concat(Fb(r.slice(s).split(`
85
+ `)))}let i=Eb.exec(r);if(i){let r=i[1],a=[];for(n++;n<e.length&&!e[n].trim().startsWith(r);)a.push(e[n++]);n++,t.push({t:`code`,lang:i[2].toLowerCase(),code:a.join(`
86
+ `)});continue}let a=Db.exec(r);if(a){t.push({t:`h`,level:a[1].length,text:a[2]??``}),n++;continue}if(Ob.test(r)){t.push({t:`hr`}),n++;continue}if(Ab.test(r)){let r=[];for(;n<e.length&&!Nb(e[n])&&(Ab.test(e[n])||!Pb(e[n]));)r.push(Ab.exec(e[n])?.[1]??e[n]),n++;let i=r.length>0?wb.exec(r[0]):null;i?t.push({t:`alert`,tone:Tb[i[1].toUpperCase()],blocks:Fb(r.slice(1))}):t.push({t:`quote`,blocks:Fb(r)});continue}let o=kb.exec(r);if(o){let r=/\d/.test(o[2]),i=r?parseInt(o[2],10):1,a=[];for(;n<e.length;){let t=kb.exec(e[n]);if(!t||/\d/.test(t[2])!==r)break;let i=t[1].length+t[2].length+Math.max(1,Math.min(t[3].length,4)),o=[t[4]];for(n++;n<e.length;){let t=e[n];if(Nb(t)){let t=e[n+1];if(t!==void 0&&/^\s+/.test(t)&&t.search(/\S/)>=i){o.push(``),n++;continue}break}let r=t.search(/\S/);if(r>=i||r>=2&&kb.test(t.trimStart()))o.push(t.slice(Math.min(r,i)));else if(!Pb(t)&&!kb.test(t))o.push(t);else break;n++}if(a.push(Fb(o)),n<e.length&&Nb(e[n])){let t=e[n+1];if(t!==void 0&&kb.test(t)&&/\d/.test(kb.exec(t)?.[2]??``)===r){n++;continue}break}}t.push({t:`list`,ordered:r,start:i,items:a});continue}if(r.includes(`|`)&&n+1<e.length&&jb.test(e[n+1])&&e[n+1].includes(`-`)){let i=Mb(r),a=Mb(e[n+1]).map(e=>e.startsWith(`:`)&&e.endsWith(`:`)?`center`:e.endsWith(`:`)?`right`:e.startsWith(`:`)?`left`:null),o=[];for(n+=2;n<e.length&&!Nb(e[n])&&e[n].includes(`|`);)o.push(Mb(e[n++]));t.push({t:`table`,head:i,align:a,rows:o});continue}let s=[r];for(n++;n<e.length&&!Nb(e[n])&&!Pb(e[n]);)s.push(e[n++]);t.push({t:`p`,text:s.join(`
87
+ `)})}return t}function Ib(e){let t=e.trim();if(!t)return;let n=/^([a-z][a-z0-9+.-]*):/i.exec(t);return n?[`http`,`https`,`mailto`].includes(n[1].toLowerCase())?t:void 0:t}let Lb=/^(?:\.{1,2}\/)?(?:[\w.-]+\/)*[\w.-]+\.[A-Za-z0-9]+(?::\d+(?:-\d+)?)?$/,Rb=e=>Lb.test(e)&&(e.includes(`/`)||/:\d/.test(e)),zb=[`javascript`,`data`,`vbscript`],Bb=e=>({...e,seen:/* @__PURE__ */ new Set}),Vb=e=>({...e,seen:void 0}),Hb=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\u3000-\u303f\uff00-\uffef]/u;function Ub(e,t){let n=null,r=[],i=``,a=()=>{i&&t.termRe&&t.terms&&t.seen?r.push(...jv(i,kv(i,t.terms,t.termRe,t.termsMark,t.seen),t.terms,t.k)):i&&r.push(i),i=``},o=0;for(;o<e.length;){let c=e[o];if(c===`\\`&&o+1<e.length&&/[\\`*_{}[\]()#+\-.!|<>~]/.test(e[o+1]))i+=e[o+1],o+=2;else if(c===`\\`&&e[o+1]===`
88
88
  `)a(),r.push(/* @__PURE__ */ (0,A.jsx)(`br`,{},t.k())),o+=2;else if(c===`
89
- `){if(/ {2,}$/.test(i))i=i.replace(/ +$/,``),a(),r.push(/* @__PURE__ */ (0,A.jsx)(`br`,{},t.k()));else{i=i.replace(/ +$/,``);let t=i.at(-1)??(typeof r.at(-1)==`string`?String(r.at(-1)).at(-1):``),n=e.slice(o+1).trimStart()[0]??``;for(!Rb.test(t??``)&&!Rb.test(n)&&(i+=` `);e[o+1]===` `;)o++}o++}else{if(c==="`"){let n=/^`+/.exec(e.slice(o))?.[0]??"`",i=e.indexOf(n,o+n.length);if(i>0){a();let c=e.slice(o+n.length,i).replace(/\n/g,` `);/^ .* $/.test(c)&&(c=c.slice(1,-1)),r.push(s(c,t)),o=i+n.length;continue}}if(c===`<`){let n=/^<((?:https?:|mailto:)[^\s<>]+)>/i.exec(e.slice(o));if(n){a(),r.push(Hb(n[1],[n[1].replace(/^mailto:/i,``)],t)),o+=n[0].length;continue}let i=/^<!--[\s\S]*?-->|^<\/?[A-Za-z][\w-]*(?:\s[^<>]*)?\/?>/.exec(e.slice(o));if(i){o+=i[0].length;continue}}if(c===`!`&&e[o+1]===`[`){let t=/^!\[([^\]]*)\]\([^)]*\)/.exec(e.slice(o));if(t){i+=t[1],o+=t[0].length;continue}}if(c===`[`){let i=Bb(e,o);if(i){if(i.href.trim().toLowerCase()===`ai:`){let t=i.text.trim();n=t&&t!==`AI`?t:``,o=i.end,e[o]===` `&&o++;continue}a();let s=/^term:(.*)$/i.exec(i.href.trim())?.[1];if(s!==void 0){let e=s;try{e=decodeURIComponent(s)}catch{}let n=t.terms?.find(t=>t.term===e);G(!n,`Markdown`,`[${i.text}](term:${s}) 找不到 terms 裡 term 為「${e}」的項目,只顯示文字。把它加進 terms,或改 term: 後面的字。`),t.seen?.add(e),r.push(n?Ev(n,t.k(),zb(i.text,Lb(t))):/* @__PURE__ */ (0,A.jsx)(y.Fragment,{children:zb(i.text,Lb(t))},t.k())),o=i.end;continue}let c=/^\s*`([^`]+)`\s*$/.exec(i.text)?.[1];r.push(Hb(i.href,zb(i.text,Lb(t)),t,c)),o=i.end;continue}}if(c===`*`||c===`_`){let n=e[o+1]===c?c+c:c,i=e[o-1],s=c===`_`&&i!==void 0&&/\w/.test(i),l=e[o+n.length];if(!s&&l&&!/\s/.test(l)){let i=Vb(e,o+n.length,n);if(i>0){a();let s=zb(e.slice(o+n.length,i),t);r.push(n.length===2?/* @__PURE__ */ (0,A.jsx)(`strong`,{children:s},t.k()):/* @__PURE__ */ (0,A.jsx)(`em`,{children:s},t.k())),o=i+n.length;continue}}}i+=c,o++}}if(a(),n!=null){let e=r[r.length-1];typeof e==`string`&&(r[r.length-1]=e.replace(/\s+$/,``)),r.push(/* @__PURE__ */ (0,A.jsx)(gb,{text:n||void 0},t.k()))}return r;function s(e,t){let n=t.onRef;if(Pb(e)){let r=t.refHref?.(e)||void 0,i=n?t=>{r&&(t.metaKey||t.ctrlKey||t.shiftKey||t.button===1)||(t.preventDefault(),n(e,t))}:void 0;if(r)return/* @__PURE__ */ (0,A.jsx)(K_,{look:`location`,href:r,onClick:i,children:e},t.k());if(i)return/* @__PURE__ */ (0,A.jsx)(K_,{look:`location`,onClick:i,children:e},t.k())}return/* @__PURE__ */ (0,A.jsx)(K_,{children:e},t.k())}}function Bb(e,t){let n=0,r=t;for(;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===`[`)n++;else if(e[r]===`]`&&--n===0)break;if(r>=e.length||e[r+1]!==`(`)return null;let i=r+2;for(;e[i]===` `;)i++;let a=0,o=``;for(;i<e.length;i++){let t=e[i];if(/\s/.test(t))break;if(t===`(`)a++;else if(t===`)`){if(a===0)break;a--}o+=t}let s=/^(?:\s+(?:"[^"]*"|'[^']*'))?\s*\)/.exec(e.slice(i));return s?{text:e.slice(t+1,r),href:o.replace(/^<(.*)>$/,`$1`),end:i+s[0].length}:null}function Vb(e,t,n){let r=t;for(;(r=e.indexOf(n,r))>0;){let t=e[r-1],i=e[r+n.length];if(t&&!/\s/.test(t)&&!(n[0]===`_`&&i&&/\w/.test(i))&&(n.length!==1||i!==n))return r;r+=n.length}return-1}function Hb(e,t,n,r){let i=/^([a-z][a-z0-9+.-]*):/i.exec(e.trim())?.[1].toLowerCase(),a=!!i&&!Fb.includes(i)&&!!n.schemes?.some(e=>e.toLowerCase()===i),o=a?e.trim():Mb(e);if(o===void 0)return/* @__PURE__ */ (0,A.jsx)(y.Fragment,{children:t},n.k());let s=n.linkHref?n.linkHref(o)||void 0:a?void 0:o;if(!s&&!n.onLink)return/* @__PURE__ */ (0,A.jsx)(y.Fragment,{children:t},n.k());let c=!!s&&/^https?:/i.test(s),l=n.onLink,u=l?e=>{s&&(e.metaKey||e.ctrlKey||e.shiftKey||e.button===1)||(e.preventDefault(),l(o,e))}:void 0;if(r!==void 0&&(!c||n.onLink)){if(s)return/* @__PURE__ */ (0,A.jsx)(K_,{look:`name`,href:s,onClick:u,children:r},n.k());if(u)return/* @__PURE__ */ (0,A.jsx)(K_,{look:`name`,onClick:u,children:r},n.k())}return s?/* @__PURE__ */ (0,A.jsx)(`a`,{className:`ui-md-link`,href:s,onClick:u,...c&&!n.onLink?{target:`_blank`,rel:`noopener noreferrer`}:{},children:t},n.k()):/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-md-link`,onClick:u,children:t},n.k())}let Ub={python:`py`,javascript:`js`,typescript:`js`,jsx:`js`,tsx:`js`,bash:`sh`,shell:`sh`,zsh:`sh`,console:`sh`,"c++":`c`},Wb=e=>Ub[e]??(Av(`x.`+e)===`plain`?e||`plain`:Av(`x.`+e)),Gb=/^([-+]?(?:NT\$\s?)?[\d,]+(?:\.\d+)?)(\s?)(%|[A-Za-z]{1,3}|\p{Script=Han}{1,2})$/u,Kb=/^[-+]?(?:NT\$\s?)?[\d,]+(?:\.\d+)?\s?(?:%|[A-Za-z]{1,3}|\p{Script=Han}{1,2})?$/u;function qb(e){let t=0,n=e.termsMark??`first`,r=y.useMemo(()=>wv(e.terms),[e.terms]),i={k:()=>`m`+t++,schemes:e.schemes,linkHref:e.linkHref,onLink:e.onLink,refHref:e.refHref,onRef:e.onRef,terms:e.terms,termsMark:n,termRe:r},a=String(e.children??``).replace(/\r\n?/g,`
90
- `),o=M(`ui-md`,e.size===`small`&&`is-small`,e.className);if(e.inline)return/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(o,`is-inline`),children:zb(a.trim().replace(/\n\s*\n/g,`
91
- `),Ib(i))});let s=e.topLevel??4,c=t=>t.map(t=>{switch(t.t){case`h`:{let e=`h${Math.min(6,s+t.level-1)}`;return/* @__PURE__ */ (0,A.jsx)(e,{className:`ui-md-h`,children:zb(t.text,Lb(i))},i.k())}case`p`:return/* @__PURE__ */ (0,A.jsx)(`p`,{children:zb(t.text,Ib(i))},i.k());case`hr`:return/* @__PURE__ */ (0,A.jsx)(`hr`,{},i.k());case`details`:return/* @__PURE__ */ (0,A.jsx)(Yb,{summary:zb(t.summary,Lb(i)),children:c(t.blocks)},i.k());case`alert`:return/* @__PURE__ */ (0,A.jsx)(Lg,{tone:t.tone,className:`ui-md-alert`,children:c(t.blocks)},i.k());case`quote`:return/* @__PURE__ */ (0,A.jsx)(`blockquote`,{children:c(t.blocks)},i.k());case`list`:{let e=t.items.map(e=>/* @__PURE__ */ (0,A.jsx)(`li`,{children:e.length===1&&e[0].t===`p`?zb(e[0].text,Ib(i)):c(e)},i.k()));return t.ordered?/* @__PURE__ */ (0,A.jsx)(`ol`,{start:t.start===1?void 0:t.start,children:e},i.k()):/* @__PURE__ */ (0,A.jsx)(`ul`,{children:e},i.k())}case`code`:return/* @__PURE__ */ (0,A.jsx)(Yv,{className:`ui-md-code`,code:t.code,language:Wb(t.lang),languageLabel:t.lang?void 0:!1,copy:!0,lineNumbers:!1,refHref:e.refHref,onRef:e.onRef,terms:e.terms,termsMark:n},i.k());case`table`:{let e=t.head.length,n=t.head.map((e,n)=>t.rows.length>0&&t.rows.every(e=>!e[n]||Kb.test(e[n])));return/* @__PURE__ */ (0,A.jsx)(Xb,{label:t.head.map(Jb).join(`、`),heads:t.head.map(e=>zb(e,Lb(i))),headText:t.head.map(Jb),rows:t.rows.map(t=>Array.from({length:e},(e,r)=>{let a=n[r]?Gb.exec(t[r]??``):null;return a?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[zb(a[1],Ib(i)),a[2],/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-unit`,children:a[3]})]}):zb(t[r]??``,Ib(i))})),numeric:n,align:e=>{let r=t.align[e]??(n[e]?`right`:null);return r?{textAlign:r}:void 0}},i.k())}}});return/* @__PURE__ */ (0,A.jsx)(`div`,{className:o,children:c(jb(a.split(`
92
- `)))})}let Jb=e=>e.replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/[`*_]/g,``).trim();function Yb({summary:e,children:t}){let[n,r]=y.useState(!1),i=y.useId(),a=y.useRef(null);return y.useLayoutEffect(()=>{let e=a.current;if(!e)return;if(n){e.removeAttribute(`hidden`);return}e.setAttribute(`hidden`,`until-found`);let t=()=>r(!0);return e.addEventListener(`beforematch`,t),()=>e.removeEventListener(`beforematch`,t)},[n]),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-md-details`,n&&`is-open`),children:[/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:`ui-md-summary`,"aria-expanded":n,"aria-controls":i,onClick:()=>r(!n),children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-right`,size:16,className:`ui-md-caret`}),/* @__PURE__ */ (0,A.jsx)(`span`,{children:e})]}),/* @__PURE__ */ (0,A.jsx)(`div`,{id:i,ref:a,className:`ui-md-details-body`,children:t})]})}function Xb(e){let[t,n]=y.useState(null),[r,i]=y.useState(!1),[a,o]=y.useState(!1),s=y.useRef(null),c=()=>[...s.current?.querySelectorAll(`thead th`)??[]].map(e=>Math.ceil(e.getBoundingClientRect().width)),[l,u]=y.useState([]);y.useLayoutEffect(()=>{let e=s.current;if(!e)return;let t=()=>{let t=[...e.querySelectorAll(`thead th`)].map(e=>Math.ceil(e.getBoundingClientRect().width));u(e=>e.length===t.length&&e.every((e,n)=>e===t[n])?e:t)};t();let n=U(t);return n?.observe(e),()=>n?.disconnect()},[]);let d=r=>/* @__PURE__ */ (0,A.jsxs)(`table`,{ref:r?s:void 0,className:`ui-md-table`,style:r&&t?{width:t.reduce((e,t)=>e+t,0),tableLayout:`fixed`,minWidth:0}:void 0,children:[r&&t?/* @__PURE__ */ (0,A.jsx)(`colgroup`,{children:t.map((e,t)=>/* @__PURE__ */ (0,A.jsx)(`col`,{style:{width:e}},t))}):null,/* @__PURE__ */ (0,A.jsx)(`thead`,{children:/* @__PURE__ */ (0,A.jsx)(`tr`,{children:e.heads.map((i,a)=>/* @__PURE__ */ (0,A.jsxs)(`th`,{style:e.align(a),children:[i,r?/* @__PURE__ */ (0,A.jsx)(iy,{name:e.headText[a],width:t?.[a]??l[a]??0,start:()=>(t??c())[a],onWidth:e=>{let r=(t??c()).slice();r[a]=e,n(r)},onReset:()=>n(null),onDragging:o}):null]},a))})}),/* @__PURE__ */ (0,A.jsx)(`tbody`,{children:e.rows.map((t,n)=>/* @__PURE__ */ (0,A.jsx)(`tr`,{children:t.map((t,n)=>/* @__PURE__ */ (0,A.jsx)(`td`,{className:e.numeric[n]?`is-num`:void 0,style:e.align(n),"data-label":e.headText[n],children:t},n))},n))})]});return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-md-tablebox`,a&&`is-resizing`),children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-md-table-tools`,children:/* @__PURE__ */ (0,A.jsx)(ay,{onClick:()=>i(!0)})}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-md-table-wrap`,tabIndex:0,role:`region`,"aria-label":e.label,children:d(!0)}),/* @__PURE__ */ (0,A.jsx)(oy,{open:r,onClose:()=>i(!1),children:/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-md ui-md-table-wrap`,tabIndex:0,role:`region`,"aria-label":e.label,children:d(!1)})})]})}xe(),Ce(),Fe(),ti(be,Se,Pe);let Zb=y.createContext(null),Qb=()=>typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;function $b(e){if(e)try{let t=localStorage.getItem(`ui-section:`+e);return t===`1`||t!==`0`&&void 0}catch{return}}function ex(e,t){if(e)try{localStorage.setItem(`ui-section:`+e,t?`1`:`0`)}catch{}}function tx(e){let t=y.useContext(Zb),n=y.useId(),[r,i]=y.useState(()=>$b(e.storageKey)??e.defaultOpen??!1),a=e.open??r,o=y.useCallback(t=>{e.open===void 0&&i(t),ex(e.storageKey,t),e.onOpenChange?.(t)},[e.open,e.storageKey,e.onOpenChange]),s=y.useRef(o),c=y.useRef(a);y.useLayoutEffect(()=>{s.current=o,c.current=a});let[l,u]=y.useState(a),[d,f]=y.useState(!1);l!==a&&(u(a),f(!a)),y.useEffect(()=>{if(!d)return;let e=window.setTimeout(()=>f(!1),Qb()?0:260);return()=>window.clearTimeout(e)},[d]);let p=y.useRef(null);y.useEffect(()=>{let t=p.current;if(!t||e.lazy)return;if(a){t.removeAttribute(`hidden`);return}let n=window.setTimeout(()=>t.setAttribute(`hidden`,`until-found`),Qb()?0:260),r=()=>s.current(!0);return t.addEventListener(`beforematch`,r),()=>{window.clearTimeout(n),t.removeEventListener(`beforematch`,r)}},[a,e.lazy]);let m=y.useRef(null);y.useEffect(()=>{if(!e.id)return;let t=()=>{decodeURIComponent(location.hash.slice(1))===e.id&&(c.current||s.current(!0),requestAnimationFrame(()=>m.current?.scrollIntoView?.({block:`start`,behavior:Qb()?`auto`:`smooth`})))};return t(),window.addEventListener(`hashchange`,t),()=>window.removeEventListener(`hashchange`,t)},[e.id]);let h=y.useRef(t?.all.n??0);y.useEffect(()=>{t&&t.all.n!==h.current&&(h.current=t.all.n,t.all.open!==c.current&&s.current(t.all.open))},[t,t?.all.n,t?.all.open]);let g=t?.report;y.useEffect(()=>{g?.(n,a)},[g,n,a]),y.useEffect(()=>()=>g?.(n,null),[g,n]);let _=`h${e.level??3}`,v=n+`-body`,b=!e.lazy||a||d;return/* @__PURE__ */ (0,A.jsxs)(`section`,{id:e.id,className:M(`ui-sec`,a&&`is-open`,e.className),children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-sec-row`,children:[/* @__PURE__ */ (0,A.jsx)(_,{ref:m,className:`ui-sec-h`,children:/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:`ui-sec-btn`,"aria-expanded":a,"aria-controls":v,onClick:()=>o(!a),children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-right`,size:18,className:`ui-sec-caret`}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-sec-title`,children:e.title}),e.summary!=null&&e.summary!==!1?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-sec-sum`,children:e.summary}):null]})}),e.actions?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-sec-actions`,children:e.actions}):null]}),/* @__PURE__ */ (0,A.jsx)(`div`,{id:v,className:`ui-sec-body`,children:/* @__PURE__ */ (0,A.jsx)(`div`,{ref:p,className:`ui-sec-in`,children:b?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-sec-content`,children:e.children}):null})})]})}function nx({children:e,actions:t,bar:n=!0,className:r}){let[i,a]=y.useState({n:0,open:!1}),[o,s]=y.useState({}),c=y.useCallback((e,t)=>{s(n=>t===null?e in n?Object.fromEntries(Object.entries(n).filter(([t])=>t!==e)):n:n[e]===t?n:{...n,[e]:t})},[]),l=y.useCallback(e=>a(t=>({n:t.n+1,open:e})),[]),u=Object.values(o),d=u.length===0||u.some(e=>!e),f=y.useMemo(()=>({all:i,report:c,anyClosed:d,setAll:l}),[i,c,d,l]);return/* @__PURE__ */ (0,A.jsx)(Zb.Provider,{value:f,children:/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-sec-group`,r),children:[n?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-sec-bar`,children:[t??null,/* @__PURE__ */ (0,A.jsx)(rx,{})]}):null,e]})})}function rx({className:e}){let t=y.useContext(Zb);if(!t)return null;let n=t.anyClosed;return/* @__PURE__ */ (0,A.jsx)(np,{className:M(`ui-sec-toggle`,e),icon:n?`arrows-out-line-vertical`:`arrows-in-line-vertical`,label:w(n?`全部展開`:`全部收合`),onClick:()=>t.setAll(n)})}function ix(e){return e.split(/([\u2e80-\u9fff\uff00-\uffef]+)/).map((e,t)=>t%2?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-kpi-cjk`,children:e},t):e)}function ax(e){let{label:t,value:n,unit:r,decimals:i=0,delta:a,deltaUnit:o,good:s,spark:c,compareLabel:l,size:u=`default`,verdict:d,target:f,className:p}=e,m=u===`compact`;G(m&&!!c,`KpiCard`,`size="compact" 不畫迷你折線,spark 會被忽略。拿掉 spark,或改用一般大小。`),G(e.format===`percent`&&!r,`KpiCard`,`format='percent' shows the number only; pass unit="%" for the smaller % after it.`);let h=u_(n,900),g=y.useRef(null);__(g,[n,e.format,r,i,e.compact,e.currency,S.locale]);let _=typeof a==`number`,v=_&&a>0,b=s??v,x=_?o===`pt`?w(`{n} 個百分點`,{n:a_.number(Math.abs(a),2)}):a_.percent(Math.abs(a)):``,C=null;if(!m&&c&&c.length>1){let e=Math.max(...c),t=Math.min(...c);C=f_(c.map((n,r)=>[r*160/(c.length-1),32-(n-t)/(e-t||1)*28]))}let T=r&&e.format!==`money`;return/* @__PURE__ */ (0,A.jsxs)(`section`,{className:M(`ui-kpi`,m&&`is-compact`,p),children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-kpi-label`,children:t}),/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:g,className:`ui-kpi-value`,"aria-label":g_(n,e,i)+(T?` `+r:``),children:[/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-kpi-num`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-kpi-sizer`,children:ix(g_(n,e,i))}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-kpi-live`,children:ix(g_(n*h,e,i))})]}),T?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-kpi-unit`,"aria-hidden":`true`,children:r}):null]}),C?/* @__PURE__ */ (0,A.jsx)(`svg`,{className:`ui-kpi-spark`,width:`100%`,height:36,viewBox:`0 0 160 36`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(`path`,{d:C,fill:`none`,stroke:`var(--chart-1)`,strokeWidth:2,strokeLinecap:`round`,vectorEffect:`non-scaling-stroke`})}):null,_?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-kpi-delta`,children:[/* @__PURE__ */ (0,A.jsxs)(`span`,{className:M(`ui-kpi-change`,b?`is-good`:`is-bad`),children:[v?`▲ `:`▼ `,ne(x)]}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-kpi-note`,children:l||w(`較上週`)})]}):null,d||f?d&&d.tone!==`success`?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-kpi-target ui-kpi-verdict is-`+d.tone,children:f?w(`{v}({t})`,{v:d.text,t:f}):d.text}):/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-kpi-target`,children:[d?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:d.text+w(`,`)}):null,f]}):null]})}function ox({checked:e,onChange:t,label:n,disabled:r,className:i}){let a=!!e,[o,s]=y.useState(!1),c=o?28:a?24:16,l=(28-c)/2,u=o?6:0,d=a?48-l-c-u:l,f=a?l:48-l-c-u;return/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":a,"aria-label":n,disabled:r,className:M(`ui-switch`,a&&`is-on`,i),onClick:()=>t?.(!a),onPointerDown:()=>s(!0),onPointerUp:()=>s(!1),onPointerLeave:()=>s(!1),onPointerCancel:()=>s(!1),children:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-switch-thumb`,style:{left:d,right:f,height:c,marginTop:-c/2,transition:`${hi(`left`,`right`,a)}, height var(--dur-hover) ease, margin-top var(--dur-hover) ease, background-color var(--dur-nav) ease`},children:/* @__PURE__ */ (0,A.jsx)(`svg`,{width:12,height:12,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:3.5,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(`path`,{d:a?`M5 12.5l4.5 4.5L19 7`:`M7 7l10 10M17 7L7 17`})})})})}on(),Or(),ti(an,Dr);let sx=/* @__PURE__ */ new Map,cx,lx=/(`[^`]+`|\d[\d,.]*)/;function ux(e,t,n){if(typeof e==`function`){let n=e(t);for(let e of[a_.number(t),String(t)])if(n.includes(e))return n.replace(e,``);return n}return(e??n(t)).replace(`{n}`,``)}function dx(e,t,n){let r=e===1?w(t):``;return r&&r!==t?r:w(n)}function fx(e){e.currentTarget.matches(`:focus-visible`)&&e.currentTarget.scrollIntoView?.({block:`nearest`,inline:`nearest`})}function px(){return typeof CanvasRenderingContext2D==`function`?document.createElement(`canvas`).getContext(`2d`):null}function mx(e,t,n){cx===void 0&&(cx=px());let r=cx;if(!r)return e.length*t*.6;let i=getComputedStyle(document.documentElement);return r.font=`600 ${t}px `+((n?i.getPropertyValue(`--font-mono`):i.getPropertyValue(`--font-sans`))||`sans-serif`),r.measureText(e).width}function hx(e){let[t,n]=y.useState(!1),r=y.useRef(null);return/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-lg-resize`,t&&`is-dragging`),role:`separator`,"aria-orientation":`horizontal`,"aria-label":w(`調整架構圖高度`),"aria-valuenow":e.value,"aria-valuemin":e.min,"aria-valuemax":e.max,"aria-valuetext":w(`{n} px`,{n:e.value}),tabIndex:0,onPointerDown:t=>{t.button===0&&(t.preventDefault(),t.currentTarget.setPointerCapture?.(t.pointerId),r.current={y:t.clientY,d:e.start()},n(!0))},onPointerMove:t=>{r.current&&e.onDrag(r.current.d+t.clientY-r.current.y)},onPointerUp:()=>{r.current=null,n(!1)},onPointerCancel:()=>{r.current=null,n(!1)},onDoubleClick:e.onReset,onKeyDown:t=>{t.altKey||t.metaKey||t.ctrlKey||(t.key===`ArrowUp`||t.key===`ArrowDown`?(t.preventDefault(),e.onKey(t.key===`ArrowUp`?-16:16)):t.key===`Enter`&&(t.preventDefault(),e.onReset()))},children:/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-lg-resize-grip`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsx)(`i`,{}),/* @__PURE__ */ (0,A.jsx)(`i`,{}),/* @__PURE__ */ (0,A.jsx)(`i`,{})]})})}function gx(e){let t=e.split(lx).filter(Boolean);cx===void 0&&(cx=px());let n=cx;if(!n)return e.length*9;let r=getComputedStyle(document.documentElement),i=r.getPropertyValue(`--font-sans`)||`sans-serif`,a=r.getPropertyValue(`--font-mono`)||`monospace`;return t.reduce((e,t)=>{let r=t[0]==="`"||/^\d/.test(t);return n.font=`600 12px `+(r?a:i),e+n.measureText(t[0]==="`"?t.slice(1,-1):t).width},0)}let _x=`ui-lg-labels:`,vx=e=>e.map(e=>e.id).join(`|`);function yx(e){let t=[];for(let n of e.match(/`[^`]+`|[A-Za-z0-9_./:#@-]+|\s+|[\s\S]/gu)??[]){let e=t[t.length-1],r=/\d\s*$/.test(e??``)&&!/^[A-Za-z0-9_]/.test(n);e!=null&&(r||/^[)」』、,。:;!?)\],;!?]/.test(n)||/[(「『([]$/.test(e))?t[t.length-1]=e+n:t.push(n)}let n=e=>{let n=[],r=``;for(let i of t)/^\s+$/.test(i)?r&&(r+=i):r&&gx(r.trimEnd()+i)>e?(n.push(r.trimEnd()),r=i):r+=i;return r.trim()&&n.push(r.trimEnd()),n},r=gx(e),i=[[e]];for(let e=2;e<=4;e++){let a=Math.max(...t.filter(e=>e.trim()).map(gx))-1,o=r;for(;o-a>1;){let t=(a+o)/2;n(t).length<=e?o=t:a=t}let s=n(o);s.length>i[i.length-1].length&&i.push(s)}return i}function bx(e){return e.split(lx).filter(Boolean).map((e,t)=>e[0]==="`"||/^\d/.test(e)?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-lg-code`,children:e[0]==="`"?e.slice(1,-1):e},t):e)}function xx(e,t){let n=`M${e[0][0]} ${e[0][1]}`;for(let r=1;r<e.length-1;r++){let[i,a,o]=[e[r-1],e[r],e[r+1]],s=Math.min(t,Math.abs(a[0]-i[0]+a[1]-i[1])/2,Math.abs(o[0]-a[0]+o[1]-a[1])/2),c=Math.sign(a[0]-i[0]),l=Math.sign(a[1]-i[1]),u=Math.sign(o[0]-a[0]),d=Math.sign(o[1]-a[1]);n+=` L${a[0]-c*s} ${a[1]-l*s} Q${a[0]} ${a[1]} ${a[0]+u*s} ${a[1]+d*s}`}let r=e[e.length-1];return`${n} L${r[0]} ${r[1]}`}let Sx=e=>e.filter((t,n)=>{let r=e[n-1];return!r||r[0]!==t[0]||r[1]!==t[1]}).filter((e,t,n)=>{let r=n[t-1],i=n[t+1];return!r||!i||!(r[0]===e[0]&&e[0]===i[0]||r[1]===e[1]&&e[1]===i[1])});function Cx(e){let[t,n]=y.useState(0),[r,i]=y.useState(null),a=r&&r.at===t?r:null,o=a?.nw??(e.nodeWidth||200),[s,c]=y.useState(()=>{if(!e.resizable||!e.heightKey)return 0;try{let t=Number(localStorage.getItem(`ui-lg-height:`+e.heightKey));return Number.isFinite(t)?t:0}catch{return 0}}),l=y.useCallback(t=>{if(c(t),e.heightKey)try{localStorage.setItem(`ui-lg-height:`+e.heightKey,String(Math.round(t)))}catch{}},[e.heightKey]),u=t+`#`+e.nodes.map(e=>e.id).join(`|`)+`#`+e.edges.map(e=>e.from+`>`+e.to+`:`+(e.label??``)).join(`|`),[d,f]=y.useState({key:``,n:0}),p=d.key===u?d.n:0,m=(a?.col??40)+p*24,h=a?.scale??1,g=e.nodes,_=e.selected??null;G(g.some(e=>e.fns!=null),`LayerGraph`,`fns is renamed size; pass size and, for the text under the bar, sizeLabel such as 「{n} 個函式」.`),G(g.some(e=>e.external&&e.shared),`LayerGraph`,`a node is both external and shared; it is drawn as shared. Keep one of the two.`);let v=e=>e.external&&!e.shared?void 0:e.size??e.fns,b=new Set(g.filter(e=>e.shared).map(e=>e.id)),x=g.filter(e=>!e.shared),S=x.some(e=>{if(!e.tag)return!1;let t=e.name||e.id,n=mx(e.tag,12,!1)+12+(e.tagTone===`warning`?15:0);return o-(e.external?24:28)-6-n<mx(t.slice(0,8),13,!!e.code)+ +(t.length>8)}),C=S?76:60,T=g.filter(e=>e.shared),E=e.edges.filter(e=>!b.has(e.from)&&!b.has(e.to)),D=e=>!!(e.inferred||e.declared),O=/* @__PURE__ */ new Map,k=-1/0;for(let e of x){let t=e.external?k:e.layer||0;O.set(t,[...O.get(t)??[],e])}let j=[...O.keys()].sort((e,t)=>e-t),N=Math.max(1,...j.map(e=>O.get(e)?.length??0)),P=32+N*o+(N-1)*m,I=Math.max(0,j.length-1),L=e.resizable&&s>0&&I?Math.min(200,s/h/I):0,R=j.map((e,t)=>56+(t<I?L:0)),z=0,B={},V={};j.forEach((e,t)=>{let n=O.get(e)??[],r=(P-(n.length*o+(n.length-1)*m))/2;n.forEach((e,n)=>{B[e.id]={x:r+n*(o+m),y:0},V[e.id]=t})});let H=e=>16+e*C+R.slice(0,e).reduce((e,t)=>e+t,0),ee=O.get(k)??[],te=Math.max(o,Math.min(e.nodeWidth||200,P-16)),ne=e=>{let t=ee.length===1&&ee[0].id===e?te:o;return{x:B[e].x+(o-t)/2,w:t}},W=()=>{for(let e in B)B[e].y=H(V[e]);z=H(j.length-1)+C+16+(oe[j.length-1]?.length?ue:0)},re=Math.max(1,...x.map(e=>v(e)||0)),ie=Math.max(1,...E.map(e=>e.count||0)),K=e=>!!B[e.from]&&!!B[e.to]&&V[e.to]<V[e.from],q=e=>!!B[e.from]&&!!B[e.to]&&e.from!==e.to&&V[e.to]===V[e.from],ae={},oe={},se={},ce={},le={},J={};for(let e of E)B[e.from]&&B[e.to]&&(K(e)?((le[e.from]??=[]).push(e),(J[e.to]??=[]).push(e)):((se[e.from]??=[]).push(e),q(e)?((ae[e.to]??=[]).push(e),(oe[V[e.from]]??=[]).push(e)):(ce[e.to]??=[]).push(e)));let ue=20+10*Math.max(0,(oe[j.length-1]?.length??0)-1),de=E.filter(K),fe=e=>O.get(j[V[e]])??[],pe=e=>fe(e)[fe(e).length-1]?.id===e,me=e=>fe(e)[0]?.id===e,he=e=>!pe(e.to)&&me(e.to),ge=de.filter(he),_e=de.filter(e=>!he(e));for(let e in se)se[e].sort((e,t)=>B[e.to].x-B[t.to].x);for(let e in ce)ce[e].sort((e,t)=>B[e.from].x-B[t.from].x);let ve=e=>e.id??`${e.from}->${e.to}`,ye=e.onSelectEdge,[be,xe]=y.useState(()=>{try{let t=window.localStorage.getItem(_x+(e.scrollKey??vx(e.nodes)));if(t===`1`||t===`0`)return t===`1`}catch{}return e.edgeLabels!==`hover`}),Se=!be,Ce=()=>{let t=!be;xe(t);try{window.localStorage.setItem(_x+(e.scrollKey??vx(e.nodes)),t?`1`:`0`)}catch{}},[we,Te]=y.useState(null),{ref:Ee,more:De,overflows:Oe,scrolled:ke,onScroll:Ae}=ny(),je=y.useId().replace(/:/g,``),[Me,Ne]=y.useState(`graph`),Pe=e.scrollKey??g.map(e=>e.id).join(`|`);y.useLayoutEffect(()=>{let e=Ee.current,t=sx.get(Pe);e&&t&&(e.scrollLeft=t)},[Pe,Me,Ee]);let Fe=()=>{let e=Ee.current;e&&sx.set(Pe,e.scrollLeft),Ae()},Ie=ye&&E.find(t=>ve(t)===e.selectedEdge)||null,Le=ye&&e.edges.find(t=>ve(t)===e.selectedEdge)||null,Re=new Set(g.map(e=>e.id)),ze={};for(let t of e.edges)b.has(t.to)&&t.from!==t.to&&Re.has(t.from)&&((ze[t.to]??={})[t.from]=(ze[t.to]?.[t.from]??0)+(t.count||0));let Be=!Ie&&_!=null&&b.has(_)?_:null,Ve=e=>Ie?e===Ie:!!_&&!Be&&(e.from===_||e.to===_),He=!!_||!!Ie,Ue=e=>Ie?e===Ie.from||e===Ie.to:Be?e===Be||e in(ze[Be]??{}):!_||e===_||E.some(t=>Ve(t)&&(t.from===e||t.to===e)),We=(t,n)=>{!n&&e.selectedEdge!=null&&ye?.(null),e.onSelect?.(n?null:t)},Ge=e=>g.find(t=>t.id===e)?.name||e,Ke=t=>{let n=t.count??0;return typeof e.countLabel==`function`?e.countLabel(n):(e.countLabel??dx(n,`1 次`,`{n} 次`)).replace(`{n}`,a_.number(n))},qe=e=>/^[A-Z][a-z]/.test(e)&&!/^zh/i.test(a_.locale())?e[0].toLowerCase()+e.slice(1):e,Je=/* @__PURE__ */ new Map;for(let e of E)D(e)&&e.label&&B[e.from]&&B[e.to]&&Je.set(e.label,(Je.get(e.label)??0)+1);let Ye=t=>t.declared?e.declaredLabel||w(`宣告`):e.inferredLabel||w(`推測`),Xe=e=>e.label&&(Je.get(e.label)??0)>1?w(`來自 {from},{label}`,{from:Ge(e.from),label:qe(e.label)}):e.label||Ye(e),Ze=e=>D(e)?Xe(e):Ke(e);if(ge.length){let e=Math.min(...x.map(e=>B[e.id].x)),t=Math.max(0,16+(ge.length-1)*12+20-e);for(let e in B)B[e]={x:B[e].x+t,y:B[e].y};P+=t}let Qe=()=>Math.min(...x.map(e=>B[e.id].x)),$e=()=>Math.max(0,...x.map(e=>B[e.id].x+o)),et=e=>he(e)?Qe()-20-ge.indexOf(e)*12:$e()+20+_e.indexOf(e)*12,tt=()=>Qe()-20+8,nt=()=>$e()+20-8;_e.length&&(P=Math.max(P,$e()+20+(_e.length-1)*12+16));let rt=t=>{let n=ve(t),r=e.selectedEdge===n?null:n;r&&_!=null&&e.onSelect?.(null),ye?.(r)},it=e=>Math.round(B[e.to].x+o*(ce[e.to].indexOf(e)+1)/(ce[e.to].length+1)),at={},ot={};{let e={};for(let t of E)ce[t.to]?.includes(t)&&(D(t)||Ve(t))&&(e[t.to]??=[]).push(t);for(let t in e)e[t].length<2||(at[t]=e[t].sort((e,t)=>it(t)-it(e)),ot[t]=e[t].length)}let st=()=>{let e=[],t=[],n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set,i=0,a=e=>{let t=B[e.from],n=B[e.to],r=se[e.from].indexOf(e),i=se[e.from].length,a=c(t.x,r,i),s=t.y+C,l=it(e),u=n.y,d=(r-(i-1)/2)*6,f=V[e.to]-V[e.from]>1,p=s+R[V[e.from]]/2+d,h=a;if(f){let t=(O.get(j[V[e.from]+1])??[]).map(e=>B[e.id]),n=(a+l)/2,r=[t[0].x-m/2,...t.map(e=>e.x+o+m/2)].map(e=>Math.max(8,Math.min(P-8,e)));h=r.reduce((e,t)=>Math.abs(t-n)<Math.abs(e-n)?t:e,r[0])+d}return{sx:a,sy:s,tx:l,ty:u,off:d,skip:f,y1:p,chx:h,from:f?h:a,startY:f?p:s}},s=/* @__PURE__ */ new Map,c=(e,t,n)=>Math.round(n<2?e+o/2:e+16+(o-32)*t/(n-1)),l=e=>{let t=B[e.from],n=B[e.to],r=se[e.from].indexOf(e),i=se[e.from].length,a=c(t.x,r,i),s=oe[V[e.from]].indexOf(e),l=ae[e.to].indexOf(e),u=Math.round(n.x+o-24-l*12);return{sx:a,sy:t.y+C,y:t.y+C+14+s*10,tx:u,ty:n.y+C}},u=e=>{if(q(e)){let t=l(e);return[{x:t.sx,y0:t.sy,y1:t.y},{x:t.tx,y0:t.ty,y1:t.y}]}if(K(e))return[{x:et(e),y0:B[e.to].y,y1:B[e.from].y+C}];let t=a(e);if(!t.skip)return[{x:t.sx,y0:t.sy,y1:t.y1},{x:t.tx,y0:t.y1,y1:t.ty}];let n=t.ty-R[V[e.to]-1]/2+t.off;return[{x:t.sx,y0:t.sy,y1:t.y1},{x:t.chx,y0:t.y1,y1:n},{x:t.tx,y0:n,y1:t.ty}]};for(let e in at){let t=at[e].map(e=>({e,g:a(e),w:Math.ceil(gx(Ze(e)))})),n=E.filter(t=>!at[e].includes(t)&&B[t.from]&&B[t.to]).flatMap(e=>u(e).map(e=>({k:-1,...e}))),r=t.length,i=e=>t[0].g.ty-8-16-e*28,o=[],c=(e,t)=>{e.length?e.forEach((n,r)=>c([...e.slice(0,r),...e.slice(r+1)],[...t,n])):o.push(t)};r<=6?c([...t.keys()],[]):o.push([...t.keys()]);let l=null;for(let e of o){let r=[];e.forEach((e,t)=>r[e]=i(t));let a=[...t.flatMap((e,t)=>[{k:t,x:e.g.from,y0:e.g.startY,y1:r[t]},{k:t,x:e.g.tx,y0:r[t],y1:e.g.ty-8}]),...n],o=(e,t,n)=>a.every(i=>i.k===e?!(i.x>t-1&&i.x<n+1&&i.y0<r[e]+7&&i.y1>r[e]-7):!(i.x>t-5&&i.x<n+5&&i.y0<r[e]+10&&i.y1>r[e]-10)),s=0,c=[];if(t.forEach((e,t)=>{let n=Math.max(e.g.from,e.g.tx)+8,r=Math.min(e.g.from,e.g.tx)-8;o(t,n,n+e.w)?c[t]=`right`:o(t,r-e.w,r)?c[t]=`left`:(c[t]=`right`,s++)}),(!l||s<l.fails)&&(l={fails:s,ys:r,sides:c}),!s)break}l&&t.forEach((e,t)=>s.set(e.e,{y:l.ys[t],side:l.sides[t]}))}let d=[],f=0,p=0,h=[],g=[],_={},v=[],b=[];E.forEach((t,n)=>{let r=B[t.from],i=B[t.to];if(!r||!i)return;let c=Ve(t),u=He&&!c,f=t===Ie,p=!!ye&&we===ve(t)&&!c,m=K(t),y,x,S,T,E=1,O=null,k=0,j=`right`;if(m){let e=et(t),a=he(t),s=le[t.from].indexOf(t),l=le[t.from].length,f=J[t.to].indexOf(t),p=J[t.to].length,m=[],g;if(a?me(t.from):pe(t.from))g=Math.round(r.y+C/2+(s-(l-1)/2)*10),m.push([a?r.x:r.x+o,g],[e,g]);else{let t=a?r.x+20+s*10:r.x+o-20-s*10;g=r.y-12-s*6,m.push([t,r.y],[t,g],[e,g])}let _;if(a||pe(t.to)){_=Math.round(i.y+C/2+(f-(p-1)/2)*10),x=a?i.x:i.x+o,S=_;let t=a?x-9:x+9;y=[...m,[e,_],[t,_]],T=`M${t} ${S-5} L${t} ${S+5} L${x} ${S} Z`,v.push([Math.min(x,t),Math.max(x,t),S-5,S+5]),h.push([Math.min(x,e),Math.max(x,e),_-3,_+3])}else x=i.x+o-20-f*10,_=i.y+C+12+f*6,S=i.y+C,y=[...m,[e,_],[x,_],[x,S+9]],T=`M${x-5} ${S+9} L${x+5} ${S+9} L${x} ${S} Z`,v.push([x-5,x+5,S,S+9]),h.push([x,e,_-3,_+3]);let b=m[m.length-2][0];if(h.push([Math.min(b,e),Math.max(b,e),g-3,g+3]),D(t)||c){let e=Ze(t);d.push({idx:n,e:t,text:e,tx:a?tt():nt(),ty:Math.round((g+_)/2),left:!a,r:c,dim:u,up:!0})}}else if(q(t)){let e=l(t);if(x=e.tx,S=e.ty,y=[[e.sx,e.sy],[e.sx,e.y],[e.tx,e.y],[e.tx,e.ty+9]],T=`M${x-5} ${S+9} L${x+5} ${S+9} L${x} ${S} Z`,v.push([x-5,x+5,S,S+9]),h.push([Math.min(e.sx,e.tx),Math.max(e.sx,e.tx),e.y-3,e.y+3]),D(t)||c){let r=Ze(t);d.push({idx:n,e:t,text:r,tx:Math.round((e.sx+e.tx)/2),ty:e.y,left:!1,r:c,dim:u,flat:!0})}}else{E=ce[t.to].length;let e=a(t),{sx:n,sy:r,skip:i}=e;x=e.tx,S=e.ty;let o=s.get(t),c=o?o.y:null,l=!i&&c!=null?c:e.y1;if(i){let i=c??S-R[V[t.to]-1]/2+e.off;y=[[n,r],[n,l],[e.chx,l],[e.chx,i],[x,i],[x,S-8]]}else y=[[n,r],[n,l],[x,l],[x,S-8]];k=e.from,O=c,j=o?.side??`right`,T=`M${x-5} ${S-9} L${x+5} ${S-9} L${x} ${S} Z`,v.push([x-5,x+5,S-9,S])}let N=(D(t)?1.5:1.5+5.5*((t.count||0)/ie))+(f?1.5:0)+(p?2:0),P=Sx(y);_[n]=P;for(let e=1;e<P.length;e++){let[t,r]=P[e-1],[i,a]=P[e];g.push({idx:n,box:[Math.min(t,i)-3,Math.max(t,i)+3,Math.min(r,a)-3,Math.max(r,a)+3]})}let F=xx(P,10);if(e.push(/* @__PURE__ */ (0,A.jsx)(`path`,{className:M(`ui-lg-edge`,t.declared?`is-declared`:t.inferred&&`is-inferred`,c&&`is-related`,u&&`is-dim`,p&&`is-hover`),d:F,strokeWidth:N},`p`+n)),!ye&&Se&&b.push(/* @__PURE__ */ (0,A.jsx)(`path`,{className:`ui-lg-hit is-peek`,d:F,onPointerEnter:()=>Te(ve(t)),onPointerLeave:()=>Te(null)},`h`+n)),ye&&b.push(/* @__PURE__ */ (0,A.jsx)(`path`,{className:`ui-lg-hit`,"data-edge":ve(t),d:F,role:`button`,tabIndex:0,"aria-label":w(`{from} 到 {to},{what}`,{from:Ge(t.from),to:Ge(t.to),what:Ze(t).replace(/`/g,``)}),"aria-pressed":f,onClick:e=>{e.stopPropagation(),rt(t)},onPointerEnter:()=>Te(ve(t)),onPointerLeave:()=>Te(null),onFocus:Se?()=>Te(ve(t)):void 0,onBlur:Se?()=>Te(null):void 0,onKeyDown:e=>{e.key===`Enter`||e.key===` `?(e.preventDefault(),rt(t)):e.key===`Escape`&&f&&ye(null)}},`h`+n)),e.push(/* @__PURE__ */ (0,A.jsx)(`path`,{className:M(`ui-lg-arrow`,c&&`is-related`,u&&`is-dim`),d:T},`a`+n)),!m&&!q(t)&&(D(t)||c)){let e=Ze(t);d.push({idx:n,e:t,text:e,tx:x,ty:S,left:E>1&&x<i.x+o/2,r:c,dim:u,lane:O,from:k,side:j})}});let S=[...v,...h],T=x.map(e=>[ne(e.id).x,ne(e.id).x+ne(e.id).w,B[e.id].y,B[e.id].y+C]),k=(e,t,n,r)=>S.some(i=>e<i[1]+(i[4]||0)&&i[0]<t+(i[4]||0)&&n<i[3]&&i[2]<r),N=(e,t,n,r,i)=>t<e[1]-1&&e[0]+1<t+n&&r<e[3]-1&&e[2]+1<i,F=(e,t,n,r,i)=>Math.hypot(Math.max(0,e[0]-(t+n),t-e[1]),Math.max(0,e[2]-i,r-e[3])),I=(e,t,n,r,i)=>{let a=1/0,o=1/0;for(let s of g){let c=F(s.box,t,n,r,i);s.idx===e?a=Math.min(a,c):o=Math.min(o,c)}return a+4<o&&o>=8},L=(e,t=!0)=>{let n=_[e.idx]??[],r=(t,n,r,i)=>I(e.idx,t,n,r,i),i=(n,i,a,o)=>(!t||r(n,i,a,o))&&n>=8&&n+i<=P-8&&a>=2&&o<=z-2&&!k(n-2,n+i+2,a-2,o+2)&&!T.some(e=>n<e[1]+4&&e[0]<n+i+4&&a<e[3]+4&&e[2]<o+4)&&!g.some(t=>t.idx===e.idx?N(t.box,n,i,a,o):n<t.box[1]+2&&t.box[0]<n+i+2&&a<t.box[3]+2&&t.box[2]<o+2);for(let t of yx(e.text)){let r=Math.ceil(Math.max(...t.map(gx))),a=t.length*16,o=null;for(let t=1;t<n.length;t++){let[s,c]=n[t-1],[l,u]=n[t],d=Math.hypot(l-s,u-c);for(let t=0;t<=d;t+=6){let n=s+(l-s)*t/d,f=c+(u-c)*t/d,p=s===l?[[n+8,f],[n-8-r,f]]:[[n-r/2,f-6-a/2],[n-r/2,f+6+a/2]];for(let[t,n]of p){let s=Math.hypot(t+r/2-e.tx,n-e.ty);o&&s>=o.d||i(t,r,n-a/2,n+a/2)&&(o={x0:t,top:n,d:s})}}}if(o)return{x0:Math.round(o.x0),top:Math.round(o.top),lw:r,lh:a,lines:t}}return null},U=[],ee=(e,t)=>{let n=_[e.idx]??[],r=t.x0+t.lw/2,i=t.top,a=null;for(let t=0;t+1<n.length;t++){let[o,s]=n[t],[c,l]=n[t+1],u=Math.hypot(c-o,l-s);for(let t=12;t<=u-12;t+=4){let n=o+(c-o)*t/u,d=s+(l-s)*t/u,f=!g.some(t=>t.idx!==e.idx&&F(t.box,n-14,28,d-14,d+14)===0)&&!T.some(e=>n+14>e[0]&&n-14<e[1]&&d+14>e[2]&&d-14<e[3])&&!k(n-14,n+14,d-14,d+14)&&!U.some(e=>Math.hypot(e.x-n,e.y-d)<28),p=Math.hypot(n-r,d-i);(!a||f&&!a.clear||f===a.clear&&p<a.d)&&(a={x:n,y:d,d:p,clear:f})}}let o=a??{x:e.tx,y:e.ty-20};return U.push({n:U.length+1,m:e,x:Math.round(o.x),y:Math.round(o.y)}),U.length},te=(e,t,n,r=[e.text],i=!1,a=0)=>/* @__PURE__ */ (0,A.jsx)(`span`,{"aria-hidden":ye?!0:void 0,className:M(`ui-lg-label`,i&&`is-over`,a>0&&`is-numbered`,a>0&&(we===ve(e.e)||e.e===Ie)&&`is-shown`,ye&&`is-clickable`,ye&&we===ve(e.e)&&`is-hover`,e.r&&`is-related`,e.dim&&`is-dim`,Se&&!e.r&&we!==ve(e.e)&&e.e!==Ie&&`is-quiet`),style:{left:t,top:n},onClick:ye?t=>{t.stopPropagation(),rt(e.e)}:void 0,onPointerEnter:ye?()=>Te(ve(e.e)):void 0,onPointerLeave:ye?()=>Te(null):void 0,children:r.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(y.Fragment,{children:[t?/* @__PURE__ */ (0,A.jsx)(`br`,{}):null,bx(e)]},t))},`l`+e.idx),W=[],re=(e,a)=>{let o=Math.ceil(gx(e.text));if(e.flat){let r=L(e);if(!r){let a=V[e.e.from];a<j.length-1&&n.add(a),i++;let s=Math.max(8,Math.min(P-8-o,e.tx-o/2)),c=e=>k(s,s+o,e-10,e+10)||T.some(t=>s<t[1]+2&&t[0]<s+o+2&&e-10<t[3]&&t[2]<e+10),l=e.ty+14;for(let e=0;e<8&&c(l);e++)l+=18;r={x0:s,top:l,lw:o,lh:16,lines:[e.text]},t.push(te(e,r.x0,r.top,r.lines,!0,ee(e,r)));return}S.push([r.x0,r.x0+r.lw,r.top-r.lh/2-4,r.top+r.lh/2+4,6]),t.push(te(e,r.x0,r.top,r.lines));return}if(e.up){let a=_[e.idx]?.[0],s=a?L({...e,tx:a[0],ty:a[1]},!0):null;if(s){S.push([s.x0,s.x0+s.lw,s.top-s.lh/2-4,s.top+s.lh/2+4,6]),t.push(te(e,s.x0,s.top,s.lines));return}let c=t=>Math.max(8,Math.min(P-8-t,e.left?e.tx-t:e.tx)),l=Math.max(10,Math.min(z-10,e.ty)),u=(t,n,r,i)=>{let a=(e,r,i)=>t<e[1]+4&&e[0]<t+n+4&&r<e[3]+4&&e[2]<i+4,o=(r,o)=>k(t,t+n,r-4,o+4)||T.some(e=>a(e,r,o))||i&&g.some(i=>i.idx===e.idx?N(i.box,t,n,r,o):a(i.box,r,o))||i&&!I(e.idx,t,n,r,o);for(let e=0;e<=16;e++)for(let t of e?[-1,1]:[0]){let n=l+t*e*18;if(n-r/2>=2&&n+r/2<=z-2&&!o(n-r/2,n+r/2))return n}return null},d=null;for(let t of yx(e.text)){let e=Math.ceil(Math.max(...t.map(gx))),n=t.length*16,r=c(e),i=u(r,e,n,!0);if(i!=null){d={x0:r,top:i,lw:e,lh:n,lines:t};break}}if(d||=L(e),!d){let a=Math.max(0,Math.min(j.length-2,j.findIndex((t,n)=>n<j.length-1&&e.ty<H(n+1))));n.add(a),i++;let s=c(o),d=u(s,o,16,!1);d??r.add(a);let f={x0:s,top:d??l,lw:o,lh:16,lines:[e.text]};t.push(te(e,f.x0,f.top,f.lines,!0,ee(e,f)));return}S.push([d.x0,d.x0+d.lw,d.top-d.lh/2-4,d.top+d.lh/2+4,6]),t.push(te(e,d.x0,d.top,d.lines));return}let s=V[e.e.to]-1,c=s>=0?H(s)+C:0,l=t=>{let n=e.left;return n&&e.tx-8-t<0?n=!1:!n&&e.tx+8+t>P&&(n=e.tx-8-t>=0),n},u=(t,n)=>t?e.tx-8-n:Math.min(e.tx+8,P-n),d=(t,n,r,i)=>{let a=e=>t<e[1]+2&&e[0]<t+n+2&&r<e[3]+2&&e[2]<i+2;return!k(t,t+n,r,i)&&!T.some(a)&&!g.some(o=>o.idx===e.idx?N(o.box,t,n,r,i):a(o.box))},m=null;if(e.lane!=null){let t=e.lane;for(let n of yx(e.text)){if(m)break;let r=Math.ceil(Math.max(...n.map(gx))),i=n.length*16,a=Math.max(e.tx,e.from??e.tx)+8,o=Math.min(e.tx,e.from??e.tx)-8-r;for(let s of e.side===`left`?[o,a]:[a,o])!m&&d(s,r,t-i/2,t+i/2)&&(m={x0:s,top:t,lw:r,lh:i,lines:n})}}for(let t of m?[]:yx(e.text)){let n=Math.ceil(Math.max(...t.map(gx))),r=t.length*16,i=l(n);for(let a of[i,!i]){let i=u(a,n);if(!(i<0||i+n>P)){for(let a=0;a<8&&!m;a++){let o=e.ty-8-r/2-a*18;if(o-r/2<Math.max(2,c+2))break;d(i,n,o-r/2,o+r/2)&&(m={x0:i,top:o,lw:n,lh:r,lines:t})}if(m)break}}if(m)break}if(m||=L(e),!m&&!a){W.push(e);return}let h=!m;if(!m){s>=0&&n.add(s),i++;let t=(e,t,n,r)=>!k(e,e+t,n,r)&&!T.some(i=>e<i[1]+2&&i[0]<e+t+2&&n<i[3]+2&&i[2]<r+2);for(let n of yx(e.text)){let r=Math.ceil(Math.max(...n.map(gx))),i=n.length*16,a=l(r);for(let o of[a,!a]){let a=u(o,r);if(!(a<0||a+r>P)){for(let o=0;o<8&&!m;o++){let s=e.ty-8-i/2-o*18;if(s-i/2<Math.max(2,c+2))break;t(a,r,s-i/2,s+i/2)&&(m={x0:a,top:s,lw:r,lh:i,lines:n})}if(m)break}}if(m)break}if(!m){s>=0&&r.add(s);let t=u(l(o),o),n=e.ty-16;for(let e=0;e<8&&k(t,t+o,n-8,n+8);e++)n-=18;m={x0:t,top:n,lw:o,lh:16,lines:[e.text]}}}h?t.push(te(e,m.x0,m.top,m.lines,!0,ee(e,m))):(S.push([m.x0,m.x0+m.lw,m.top-m.lh/2-4,m.top+m.lh/2+4,6]),f=Math.max(f,m.x0+m.lw+8+4),p=Math.min(p,m.x0-8-4),t.push(te(e,m.x0,m.top,m.lines,h)))};d.sort((e,t)=>Number(!!e.up)-Number(!!t.up)||e.ty-t.ty||e.tx-t.tx).forEach(e=>re(e,!1)),W.forEach(e=>re(e,!0));for(let e of U)t.push(/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-lg-num`,e.m.dim&&`is-dim`,(we===ve(e.m.e)||e.m.e===Ie)&&`is-on`),style:{left:e.x,top:e.y},"aria-hidden":`true`,onPointerEnter:ye?()=>Te(ve(e.m.e)):void 0,onPointerLeave:ye?()=>Te(null):void 0,children:e.n},`n`+e.m.idx));return{paths:e,labels:t,hitPaths:b,need:n,crowd:r,wide:f,least:p,covered:i,numbered:U}};for(let e in ot){let t=V[e]-1;t>=0&&(R[t]=Math.max(R[t],ot[e]*28+40))}let ct=R.slice();W();let lt=st(),ut=()=>[...lt.need].filter(e=>R[e]<ct[e]+144);for(let e=0;e<6&&ut().length;e++){for(let e of ut())R[e]=Math.min(ct[e]+144,R[e]+24);W(),lt=st()}let dt=[...lt.need].filter(e=>R[e]>=ct[e]+144);if(dt.length){for(let e of dt)R[e]=ct[e];W(),lt=st();let e=()=>[...lt.crowd].filter(e=>dt.includes(e)&&R[e]<ct[e]+144);for(let t=0;t<6&&e().length;t++){for(let t of e())R[t]=Math.min(ct[t]+144,R[t]+24);W(),lt=st()}}for(let e=0;e<3&&lt.least<0;e++){let e=Math.ceil(-lt.least);for(let t in B)B[t].x+=e;P+=e,lt=st()}lt.wide>P&&(P=Math.ceil(lt.wide),lt=st());let{paths:ft,labels:pt,hitPaths:mt,numbered:ht}=lt,gt=Math.min(...x.filter(e=>B[e.id]).map(e=>ne(e.id).x),P),_t=_!=null&&B[_]?ne(_):null,vt=t=>ux(e.sizeLabel,t,()=>dx(t,`1 個項目`,`{n} 個項目`)),yt=e.externalLabel??w(`repo 外`),bt=e.useLabel??w(`使用 {n} 次`),xt=e=>e.tag?/* @__PURE__ */ (0,A.jsxs)(`span`,{className:M(`ui-lg-tag`,e.tagTone===`warning`&&`is-warning`),children:[e.tagTone===`warning`?/* @__PURE__ */ (0,A.jsx)(Y,{name:`lock`,size:12}):null,e.tag]}):null,St=x.map(t=>{let n=B[t.id],r=t.id===_,i=v(t),a=Be?ze[Be]?.[t.id]:void 0;return/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-lg-node`,t.external&&`is-external`,r&&`is-selected`,!Ue(t.id)&&`is-dim`),onFocus:fx,style:{left:ne(t.id).x,top:n.y,width:ne(t.id).w,height:C},"aria-pressed":e.onSelect?r:void 0,onClick:e.onSelect?()=>We(t.id,r):void 0,children:[/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-lg-head`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-lg-name`,t.code&&`is-code`),children:t.name||t.id}),S?null:xt(t),a?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-lg-use`,children:F(bt.replace(`{n}`,``),[a])}):null]}),S?xt(t):null,t.external?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-lg-ext`,children:yt}):null,i==null?null:/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-lg-size`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-lg-track`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(`span`,{style:{width:Math.round(i/re*100)+`%`}})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-lg-count`,children:F(vt(i),[a_.number(i)])})]})]},t.id)}),Ct=e.sharedMeta??w(`{a} 個項目使用,共 {b} 次`),wt=T.map(t=>{let n=ze[t.id]??{},r=Object.values(n).reduce((e,t)=>e+t,0),i=t.id===_,a=!!Ie||_!=null&&!i&&(Be==null?!(_ in n):!(t.id in(ze[Be]??{}))&&!(Be in n));return/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-lg-node`,`ui-lg-chip`,i&&`is-selected`,a&&`is-dim`),onFocus:fx,"aria-pressed":e.onSelect?i:void 0,onClick:e.onSelect?()=>We(t.id,i):void 0,children:[/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-lg-head`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-lg-name`,t.code&&`is-code`),children:t.name||t.id}),xt(t)]}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-lg-shared-meta`,children:F(Ct.replace(`{a}`,``).replace(`{b}`,``),[Object.keys(n).length,r])})]},t.id)}),Tt=e=>D(e)?e.label?w(`{label}({inferred})`,{label:e.label,inferred:Ye(e)}):Ye(e):Ke(e),Et=(e,t,n,r,i,a)=>/* @__PURE__ */ (0,A.jsxs)(`li`,{className:M(`ui-lg-li`,n&&`is-dim`),children:[r?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:M(`ui-lg-libtn`,t&&`is-selected`),"aria-pressed":t,onClick:r,children:i}):/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-lg-lihead`,children:i}),a]},e),Dt=new Set(g.map(e=>e.id)),Ot=/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-lg-list`,children:[/* @__PURE__ */ (0,A.jsxs)(`section`,{"aria-labelledby":`${je}-ln`,children:[/* @__PURE__ */ (0,A.jsx)(`h3`,{id:`${je}-ln`,className:`ui-lg-listtitle`,children:e.listLabels?.nodes??w(`項目`)}),/* @__PURE__ */ (0,A.jsx)(`ul`,{children:g.map(t=>{let n=v(t);return Et(t.id,t.id===_,!Ue(t.id),e.onSelect?()=>We(t.id,t.id===_):void 0,/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-lg-liname`,t.code&&`ui-lg-code`),children:t.name||t.id}),xt(t)]}),t.external&&!t.shared?/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-lg-limeta`,children:[w(`,`),yt]}):n==null?null:/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-lg-limeta`,children:[w(`,`),F(vt(n),[a_.number(n)])]}))})})]}),/* @__PURE__ */ (0,A.jsxs)(`section`,{"aria-labelledby":`${je}-le`,children:[/* @__PURE__ */ (0,A.jsx)(`h3`,{id:`${je}-le`,className:`ui-lg-listtitle`,children:e.listLabels?.edges??w(`關係`)}),/* @__PURE__ */ (0,A.jsx)(`ul`,{children:e.edges.filter(e=>Dt.has(e.from)&&Dt.has(e.to)).map((e,t)=>Et(ve(e)+`:`+t,e===Le,He&&!Ve(e)&&!(Be&&e.to===Be),ye?()=>rt(e):void 0,/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-lg-code`,children:Ge(e.from)}),` `,/* @__PURE__ */ (0,A.jsx)(`span`,{"aria-hidden":`true`,children:`→`}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:w(`到`)}),` `,/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-lg-code`,children:Ge(e.to)}),/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-lg-limeta`,children:[w(`:`),bx(Tt(e))]})]}),null))})]})]}),kt=e.listView!==!1&&Me===`list`,At=y.useRef(``);y.useLayoutEffect(()=>{let e=Ee.current;if(!e||kt||!a?.full||At.current===Pe||(At.current=Pe,sx.get(Pe)))return;let t=_t?_t.x+_t.w/2-e.clientWidth/(2*h):gt-16;e.scrollLeft=Math.max(0,t*h)});let jt=_t?.x,Mt=_t?.w;y.useEffect(()=>{let e=Ee.current;if(!e||kt||jt==null||Mt==null)return;let t=jt*h,n=(jt+Mt)*h;t<e.scrollLeft?e.scrollLeft=Math.max(0,t-16):n>e.scrollLeft+e.clientWidth&&(e.scrollLeft=n-e.clientWidth+16)},[_,jt,Mt,h,kt,Ee]);let Nt=e.labelToggle!==!1&&!kt&&e.edges.some(e=>D(e));y.useLayoutEffect(()=>{let e=Ee.current;if(!e)return;let t=()=>n(e.clientWidth);t();let r=U(t);return r?.observe(e),()=>r?.disconnect()},[Ee,kt]),y.useLayoutEffect(()=>{if(!t||kt)return;if(!a){if(P<=t+.5)return;let n=e.nodeWidth||200,r=P-t-(N-1)*16,a=Math.max(Math.min(n,120),Math.floor(n-Math.max(0,r)/N));i({at:t,nw:a,col:24,scale:1});return}if(a.full)return;let n=Math.floor(t/P*1e3)/1e3;if(P>t+.5&&n<.75){i({...a,nw:e.nodeWidth||200,col:40,scale:1,full:!0});return}let r=P<=t+.5?1:n;r!==a.scale&&i({...a,scale:r})},[t,kt,a,P,e.nodeWidth,N]);let Pt=lt.covered;y.useLayoutEffect(()=>{Pt&&p<5&&f({key:u,n:p+1})},[Pt,p,u]);let Ft=z*h,It=Ft-Math.max(0,s),Lt=e.resizable&&s<0?Math.max(Math.min(160,It),It+s):null,Rt=e=>Math.max(Math.min(160,It)-It,Math.min(e,I?200*I*h:0));return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-graph ui-lg`,e.className),children:[e.listView===!1&&!Nt&&!e.toolbar?null:/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-lg-bar`,children:[e.toolbar?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-lg-toolbar`,children:e.toolbar}):null,Nt&&e.labelToggle===`icon`?/* @__PURE__ */ (0,A.jsx)(np,{className:`ui-lg-labels-btn`,icon:`tag`,filled:be,label:w(`顯示線上文字`),"aria-pressed":be,onClick:Ce}):Nt?/* @__PURE__ */ (0,A.jsxs)(`label`,{className:`ui-lg-labels-switch`,children:[/* @__PURE__ */ (0,A.jsx)(ox,{checked:be,onChange:Ce,label:w(`線上文字`)}),/* @__PURE__ */ (0,A.jsx)(`span`,{"aria-hidden":`true`,children:w(`線上文字`)})]}):null,e.listView===!1?null:/* @__PURE__ */ (0,A.jsx)(ty,{label:w(`顯示方式`),value:Me,onChange:Ne,items:[{id:`graph`,label:w(`圖`)},{id:`list`,label:w(`清單`)}]})]}),kt?Ot:null,/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-lg-scroller`,De&&`has-more`,kt&&`is-hidden`),children:/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-lg-scroll`,Lt!=null&&`is-framed`),ref:Ee,onScroll:Fe,style:Lt==null?void 0:{height:Lt},children:/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-lg-canvas`,style:h===1?{width:P,height:z}:{width:P,height:z,transform:`scale(${h})`,transformOrigin:`0 0`,marginRight:P*(h-1),marginBottom:z*(h-1),"--lg-scale":h},role:`group`,"aria-label":e.label||w(`架構圖`),onClick:ye&&e.selectedEdge!=null?()=>ye(null):void 0,children:[/* @__PURE__ */ (0,A.jsx)(`svg`,{width:P,height:z,viewBox:`0 0 ${P} ${z}`,"aria-hidden":`true`,children:ft}),St,pt,mt.length&&!ye?/* @__PURE__ */ (0,A.jsx)(`svg`,{className:`ui-lg-hits`,width:P,height:z,viewBox:`0 0 ${P} ${z}`,"aria-hidden":`true`,children:mt}):mt.length?/* @__PURE__ */ (0,A.jsx)(`svg`,{className:`ui-lg-hits`,width:P,height:z,viewBox:`0 0 ${P} ${z}`,role:`group`,"aria-label":w(`關係`),children:mt}):null]})})}),e.resizable&&!kt?/* @__PURE__ */ (0,A.jsx)(hx,{value:Math.round(Ft+Math.min(0,s)),min:Math.round(Math.min(160,Ft)),max:Math.round(Ft-Math.max(0,s)+200*I*h),onDrag:e=>l(Rt(e)),onKey:e=>l(Rt(s+e)),onReset:()=>l(0),start:()=>s}):null,kt?null:/* @__PURE__ */ (0,A.jsx)(ry,{show:Oe,done:ke}),kt||!ht.length?null:/* @__PURE__ */ (0,A.jsx)(`ol`,{className:`ui-lg-numlist`,"aria-label":w(`編號的線`),children:ht.map(e=>/* @__PURE__ */ (0,A.jsxs)(`li`,{className:M(e.m.dim&&`is-dim`),children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-lg-num is-static`,"aria-hidden":`true`,children:e.n}),/* @__PURE__ */ (0,A.jsx)(`span`,{children:bx(e.m.text)})]},e.n))}),T.length&&!kt?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-lg-shared`,children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-lg-shared-title`,children:e.sharedLabel||w(`共用項目`)}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-lg-chips`,children:wt})]}):null,kt||e.legend===!1||!e.legendItems&&!E.some(e=>B[e.from]&&B[e.to])?null:/* @__PURE__ */ (0,A.jsx)(hb,{items:e.legendItems||[...E.some(e=>!D(e)&&B[e.from]&&B[e.to])?[{type:`weight`,label:`次數越多線越粗`}]:[],...E.some(e=>e.inferred&&!e.declared&&B[e.from]&&B[e.to])?[{type:`inferred`,label:e.inferredLabel||`推測的關係`,text:e.inferredText}]:[],...E.some(e=>e.declared&&B[e.from]&&B[e.to])?[{type:`declared`,label:e.declaredLegend||`專案宣告的關係`,text:e.declaredText}]:[]]})]})}function wx({segments:e,classes:t,label:n,count:r,times:i,legend:a=!0,className:o}){let s=e=>m_(Math.max(0,t.findIndex(t=>t.value===e))),c=e=>t.find(t=>t.value===e)?.label??e,l=e.map(e=>(i?i[e.from]+` `+w(`到`)+` `+(i[e.to]??i[i.length-1])+` `:``)+c(e.value)).join(w(`,`));return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-statusband`,o),children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-statusband-bar`,role:`img`,"aria-label":n+w(`:`)+(l||w(`沒有資料`)),children:e.map((e,t)=>/* @__PURE__ */ (0,A.jsx)(`span`,{style:{left:e.from/r*100+`%`,width:(Math.min(r,e.to)-e.from)/r*100+`%`,background:s(e.value)}},t))}),a?/* @__PURE__ */ (0,A.jsx)(Tx,{classes:t,label:n}):null]})}function Tx({classes:e,label:t}){return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-chart-legend ui-statusband-legend`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{children:t}),e.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`span`,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-chart-swatch`,style:{background:m_(t)}}),e.label]},e.value))]})}function Ex(e,t,n){let r=[],i=[];return e.forEach((e,a)=>{e==null||Number.isNaN(e)?(i.length&&r.push(i),i=[]):i.push([t(a),n(e)])}),i.length&&r.push(i),r}let Dx=(e,t)=>e?.color?m_(e.color-1):m_(t);function Ox({series:e,labels:t,label:n,unit:r,decimals:i,max:a,min:o=0,labelEvery:s=1,band:c,now:l,thresholds:u,marker:d,playhead:f,onPlayheadChange:p,headline:m,status:h,empty:g,height:_=240,className:v}){let[b,x]=y.useState(-1),S=y.useRef(null),[C,T]=y.useState(640);y.useLayoutEffect(()=>{let e=S.current;if(!e)return;let t=()=>{e.clientWidth>0&&T(e.clientWidth)};if(t(),typeof ResizeObserver!=`function`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let E=C-10,D=_-30,O=`ui-stripes-`+y.useId().replace(/:/g,``),k=y.useRef(!1),j=e.flatMap(e=>e.values.filter(e=>e!=null)),N=a??y_(Math.max(o+1,...j,...(u??[]).map(e=>e.value))-o)+o,P=t.length||e[0]?.values.length||0,F=(E-40)/Math.max(1,P-1),I=e=>40+e*F,L=e=>D-(e-o)/(N-o)*(D-10),R=h_.map(e=>o+e*(N-o)),z=r?` `+r:``,B=e=>e==null?`—`:a_.number(e,i)+z,V=f!=null&&!!p,H=n=>{x(n),bi(t[n]+w(`:`)+e.filter(e=>e.values[n]!=null).map(t=>(e.length>1?t.name+` `:``)+B(t.values[n])).join(w(`,`)))},U=e=>{V&&p(e),H(e)},ee=e=>{let t=e.currentTarget.getBoundingClientRect(),n=(e.clientX-t.left)/t.width*C;return Math.max(0,Math.min(P-1,Math.round((n-40)/F)))},te={left:(40-F/2)/C*100+`%`,right:(C-E-F/2)/C*100+`%`},W=e.length>1||c,re=Math.max(0,...t.map(e=>e.length))*7.5+12,ie=Math.max(s,Math.ceil(P*re/Math.max(1,E-40)/s)*s),G=d?I(d.at)+10+[...d.label].reduce((e,t)=>e+(t.charCodeAt(0)>11904?14:8),0)>C:!1,K=[];if(c){let t=e[c.between[0]]?.values??[],n=e[c.between[1]]?.values??[];for(let e=0;e<P-1;e++){let r=t[e],i=t[e+1],a=n[e],o=n[e+1];r!=null&&i!=null&&a!=null&&o!=null&&K.push({d:`M${I(e)},${L(r)} L${I(e+1)},${L(i)} L${I(e+1)},${L(o)} L${I(e)},${L(a)} Z`,up:r+i>=a+o})}}let q=t=>{let n=e.map((n,r)=>({color:Dx(e[r],r),name:n.name,value:n.values[t]})).filter(e=>e.value!=null).map(e=>({...e,value:B(e.value)}));if(c){let r=e[c.between[0]]?.values[t],i=e[c.between[1]]?.values[t];r!=null&&i!=null&&n.push({color:``,name:w(`差`),value:(r-i>0?`+`:``)+B(r-i)})}return n},ae=b>=0?b:-1;return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-chart`,v),children:[m?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-chart-headline`,children:m}):null,W?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-chart-legend`,children:[e.map((t,n)=>/* @__PURE__ */ (0,A.jsxs)(`span`,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-chart-swatch`,t.dashed&&`is-dashed`),style:{background:t.dashed?void 0:Dx(e[n],n),color:Dx(e[n],n)}}),t.name]},n)),c?/* @__PURE__ */ (0,A.jsxs)(`span`,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-chart-swatch`,`is-band`,`is-`+c.tone)}),c.label]}):null]}):null,/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:S,className:M(`ui-chart-plot`,V&&`is-replay`),tabIndex:P?0:void 0,role:`group`,"aria-label":n,"aria-description":w(V?`左右方向鍵移動播放頭`:`左右方向鍵查看每一個時間點的數值`),onMouseLeave:()=>!k.current&&x(-1),onFocus:()=>b<0&&P&&H(V?f:0),onBlur:()=>x(-1),onKeyDown:e=>{let t=b_(e,V?f:b,P);t!=null&&U(t)},onPointerDown:V?e=>{if(e.button===0){k.current=!0;try{e.currentTarget.setPointerCapture?.(e.pointerId)}catch{}U(ee(e))}}:void 0,onPointerMove:V?e=>{k.current&&U(ee(e))}:void 0,onPointerUp:()=>{k.current=!1},onPointerCancel:()=>{k.current=!1},children:[/* @__PURE__ */ (0,A.jsxs)(`svg`,{viewBox:`0 0 ${C} ${_}`,width:`100%`,height:_,"aria-hidden":`true`,children:[l!=null&&l<P-1?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`defs`,{children:/* @__PURE__ */ (0,A.jsx)(`pattern`,{id:O,width:`9`,height:`9`,patternUnits:`userSpaceOnUse`,patternTransform:`rotate(45)`,children:/* @__PURE__ */ (0,A.jsx)(`rect`,{width:`4`,height:`9`,className:`ui-chart-stripe`})})}),/* @__PURE__ */ (0,A.jsx)(`rect`,{x:I(l),y:10,width:E-I(l),height:D-10,fill:`url(#${O})`})]}):null,R.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`g`,{children:[/* @__PURE__ */ (0,A.jsx)(`line`,{x1:40,x2:E,y1:L(e),y2:L(e),className:t?`ui-chart-grid`:`ui-chart-axis`}),/* @__PURE__ */ (0,A.jsx)(`text`,{x:32,y:L(e)+4,textAnchor:`end`,className:`ui-chart-tick`,children:a_.number(e,d_(N-o))})]},t)),K.map((e,t)=>/* @__PURE__ */ (0,A.jsx)(`path`,{d:e.d,className:M(`ui-chart-band`,c?.tone===`success`?`is-success`:e.up?`is-pos`:`is-neg`)},t)),(u??[]).map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`g`,{className:`ui-chart-threshold is-`+e.tone,children:[/* @__PURE__ */ (0,A.jsx)(`line`,{x1:40,x2:E,y1:L(e.value),y2:L(e.value)}),/* @__PURE__ */ (0,A.jsx)(`text`,{x:E-2,y:L(e.value)-5,textAnchor:`end`,children:e.label})]},t)),e.map((t,n)=>Ex(t.values,I,L).map((r,i)=>/* @__PURE__ */ (0,A.jsx)(`path`,{d:f_(r),pathLength:t.dashed?void 0:1,className:M(`ui-chart-line`,t.dashed&&`is-dashed`),style:{stroke:Dx(e[n],n),animationDelay:n*150+`ms`}},n+`-`+i))),l==null?null:/* @__PURE__ */ (0,A.jsxs)(`g`,{className:`ui-chart-now`,children:[/* @__PURE__ */ (0,A.jsx)(`line`,{x1:I(l),x2:I(l),y1:6,y2:D}),/* @__PURE__ */ (0,A.jsx)(`text`,{x:I(l),y:2,textAnchor:`middle`,children:w(`現在`)})]}),d?/* @__PURE__ */ (0,A.jsxs)(`g`,{className:`ui-chart-marker`,children:[/* @__PURE__ */ (0,A.jsx)(`circle`,{cx:I(d.at),cy:L(d.value),r:5.5,style:{stroke:Dx(e[d.series??e.length-1],d.series??e.length-1)}}),/* @__PURE__ */ (0,A.jsx)(`text`,{x:I(d.at)+(G?-10:10),y:L(d.value)+20,textAnchor:G?`end`:`start`,children:d.label})]}):null,V?/* @__PURE__ */ (0,A.jsxs)(`g`,{className:`ui-chart-playhead`,children:[/* @__PURE__ */ (0,A.jsx)(`line`,{x1:I(f),x2:I(f),y1:10,y2:D}),/* @__PURE__ */ (0,A.jsx)(`circle`,{cx:I(f),cy:D,r:8})]}):null]}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-chart-hit`,style:{...te,bottom:30},children:t.map((t,n)=>/* @__PURE__ */ (0,A.jsx)(`div`,{onMouseEnter:()=>!k.current&&x(n),className:`ui-chart-col`,children:ae===n?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-chart-guide`}),e.map((t,r)=>{let i=t.values[n];return i==null?null:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-chart-dot`,style:{top:L(i)/D*100+`%`,background:Dx(e[r],r)}},r)})]}):null},n))}),j.length?null:/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-chart-empty`,children:g??w(`這段時間沒有資料`)}),ae>=0?/* @__PURE__ */ (0,A.jsx)(v_,{title:t[ae],style:{left:I(ae)/C*100+`%`,transform:ae>P*.65?`translateX(calc(-100% - 12px))`:`translateX(12px)`},rows:q(ae)}):null]}),h?/* @__PURE__ */ (0,A.jsx)(`div`,{style:{marginLeft:te.left,marginRight:te.right},children:/* @__PURE__ */ (0,A.jsx)(wx,{...h,count:P,times:t,legend:!1,className:`is-attached`})}):null,/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-chart-xlabels`,style:{marginLeft:te.left,marginRight:te.right},children:t.map((e,t)=>/* @__PURE__ */ (0,A.jsx)(`span`,{children:ie>1&&t%ie?``:ne(e)},t))}),h?/* @__PURE__ */ (0,A.jsx)(Tx,{classes:h.classes,label:h.label}):null]})}function kx({label:e,value:t,min:n,max:r,warn:i,limit:a,unit:o,decimals:s=0,className:c}){let l=r-n||1,u=e=>Math.max(0,Math.min(100,(e-n)/l*100)),d=a!=null&&t>=a?`danger`:i!=null&&t>=i?`warning`:`success`,f=w(d===`danger`?`⚠ 超過上限`:d===`warning`?`⚠ 注意`:`正常`),p=e=>a_.number(e,s)+(o?` `+o:``),m=e=>a_.number(e,(String(e).split(`.`)[1]??``).length),h=y.useRef(null),[g,_]=y.useState(!1),v=i==null?null:u(i),b=a==null?null:u(a),x=[[`var(--meter-ok)`,0,v??b??100],...v==null?[]:[[`var(--meter-warn)`,v,b??100]],...b==null?[]:[[`var(--meter-over)`,b,100]]],S=[...i==null?[]:[{v:i,at:v,tone:`warning`,text:w(`注意 {v}`,{v:m(i)})}],...a==null?[]:[{v:a,at:b,tone:`danger`,text:w(`上限 {v}`,{v:m(a)})}]];return y.useLayoutEffect(()=>{let e=h.current;if(!e)return;let t=()=>{let[t,n]=[...e.children].map(e=>e.getBoundingClientRect());_(!!t&&!!n&&t.right+8>n.left&&t.left<n.right+8)};t();let n=typeof ResizeObserver==`function`?new ResizeObserver(t):null;return n?.observe(e),()=>n?.disconnect()},[i,a,n,r]),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-meter`,c),role:`meter`,"aria-label":e,"aria-valuenow":t,"aria-valuemin":n,"aria-valuemax":r,"aria-valuetext":p(t)+w(`,`)+f.replace(`⚠ `,``)+S.map(e=>w(`,`)+e.text).join(``),children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-meter-head`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-meter-label`,children:e}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-meter-state is-`+d,children:f}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-meter-value`,children:p(t)})]}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-meter-track`,"aria-hidden":`true`,style:{background:`linear-gradient(90deg, ${x.map(([e,t,n])=>`${e} ${t}% ${n}%`).join(`, `)})`},children:[S.map(e=>/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-meter-mark is-`+e.tone,style:{left:e.at+`%`}},e.tone)),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-meter-dot is-`+d,style:{left:u(t)+`%`}})]}),S.length?/* @__PURE__ */ (0,A.jsx)(`div`,{ref:h,className:M(`ui-meter-marks`,g&&`is-stacked`),"aria-hidden":`true`,children:S.map(e=>/* @__PURE__ */ (0,A.jsx)(`span`,{className:`is-`+e.tone,style:e.tone===`warning`&&S.length>1?{right:100-e.at+`%`}:e.at>80?{right:0}:{left:e.at+`%`},children:e.text},e.tone))}):null]})}let Ax=/^(heat-[1-7]|diverge-(neg|pos)(-strong)?|diverge-zero|chart-[1-4])$/;function jx({zones:e,label:t,columns:n=4,rowHeight:r=120,fill:i=!1,min:a=20,max:o=30,selectedId:s,onSelect:c,className:l}){return/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-zonemap`,i&&`is-fill`,l),role:`group`,"aria-label":t,style:{"--zone-cols":n,gridAutoRows:i?`minmax(${r}px, 1fr)`:r+`px`},children:e.map(e=>{let t=e.area?{gridRow:`${e.area.row} / span ${e.area.rows??1}`,gridColumn:`${e.area.col} / span ${e.area.cols??1}`}:void 0;if(e.value==null&&!e.forecast)return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-zone is-empty`,style:t,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-zone-name`,children:e.name}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-zone-detail`,children:w(`沒有資料`)})]},e.id);let n=e.tone??`normal`,r=e.fill??(e.value==null?`surface-sub`:Am(e.value,a,o)),i=/^[a-z][a-z0-9-]*$/.test(r)?`var(--${r})`:r,l=(n===`normal`?``:`⚠ `)+(e.state??(e.forecast?w(`預測`):w(`正常`))),u=e.value==null?`—`:a_.number(e.value,e.decimals??1),d=s===e.id;return/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-zone`,`is-`+n,e.forecast&&`ui-forecast`,d&&`is-selected`),"data-fill":r,style:{...t,background:i,color:Ax.test(r)?void 0:km(r)},"aria-pressed":d,"aria-label":[e.name,u+(e.unit?` `+e.unit:``),l.replace(`⚠ `,``),e.detail].filter(Boolean).join(w(`,`)),onClick:()=>c?.(e),children:[/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-zone-head`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-zone-name`,children:e.name}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-zone-state`,children:l})]}),/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-zone-value`,children:[u,e.unit?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-zone-unit`,children:e.unit}):null]}),e.detail?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-zone-detail`,children:e.detail}):null]},e.id)})})}Rr(),Br(),Xn(),er(),ti(Lr,zr,Yn,$n);let Mx={alert:{icon:`warning`,name:`告警`},switch:{icon:`arrows-left-right`,name:`切換`},ai:{icon:`sparkle`,name:`AI`},manual:{icon:`user`,name:`人工`}};function Nx({events:e,label:t,empty:n,className:r}){let i=[...e].sort((e,t)=>t.time.getTime()-e.time.getTime());return i.length?/* @__PURE__ */ (0,A.jsx)(`ol`,{className:M(`ui-events`,r),"aria-label":t,children:i.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`li`,{className:`is-`+e.kind,children:[/* @__PURE__ */ (0,A.jsx)(`time`,{className:`ui-events-time`,dateTime:e.time.toISOString(),children:a_.time(e.time)}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-events-kind`,role:`img`,"aria-label":w(Mx[e.kind].name),children:/* @__PURE__ */ (0,A.jsx)(Y,{name:Mx[e.kind].icon,size:20})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-events-text`,children:e.text})]},e.id??t))}):/* @__PURE__ */ (0,A.jsx)(`p`,{className:M(`ui-events-empty`,r),children:n??w(`沒有事件`)})}Wr(),Te(),ti(Ur,we);function Px(e,t){return Math.max(1,Math.min(1.5,Math.min(e/1440,t/900)))}function Fx({title:e,tags:t,status:n,kpis:r,clock:i,fullscreen:a=!0,main:o,side:s,bottom:c,extras:l,className:u}){let d=y.useRef(null),[f,p]=y.useState(null),[m,h]=y.useState(!1),g=typeof document<`u`&&document.fullscreenEnabled===!0;y.useLayoutEffect(()=>{let e=d.current;if(!e)return;let t=()=>p({w:e.clientWidth,h:e.clientHeight});if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),y.useEffect(()=>{let e=()=>h(document.fullscreenElement!=null&&document.fullscreenElement===d.current);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let _=()=>{let e=d.current;e&&(document.fullscreenElement?document.exitFullscreen().catch(()=>void 0):e.requestFullscreen().catch(()=>void 0))},v=f!=null&&f.w<600,b=f&&!v?Px(f.w,f.h):1,x=f?f.h/b:0,S=(l??[]).filter(e=>v||x>=e.minHeight),C=f&&!v&&b!==1?{zoom:b,width:f.w/b,height:f.h/b}:void 0,T=/* @__PURE__ */ (0,A.jsxs)(`header`,{className:`ui-console-top`,children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-console-start`,children:[/* @__PURE__ */ (0,A.jsx)(`h1`,{className:`ui-console-title`,children:e}),t]}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-console-end`,children:[n==null?null:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-console-status`,children:n}),r==null?null:/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-console-kpis`,children:r}),i==null?null:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-console-clock`,children:i}),a&&g&&!v?/* @__PURE__ */ (0,A.jsx)(np,{label:w(m?`離開全螢幕`:`全螢幕`),icon:m?`corners-in`:`corners-out`,onClick:_}):null]})]});return/* @__PURE__ */ (0,A.jsx)(`div`,{ref:d,className:M(`ui-console`,v&&`is-stacked`,u),children:/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-console-frame`,style:C,children:[T,/* @__PURE__ */ (0,A.jsx)(`main`,{className:`ui-console-main`,children:o}),v?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[s,c,S.map(e=>/* @__PURE__ */ (0,A.jsx)(y.Fragment,{children:e.node},e.id))]}):/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsxs)(`aside`,{className:`ui-console-side`,"aria-label":w(`側欄`),children:[s,S.map(e=>/* @__PURE__ */ (0,A.jsx)(y.Fragment,{children:e.node},e.id))]}),c==null?null:/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-console-bottom`,children:c})]})]})})}function Ix({time:e,replaying:t,onReplayChange:n,onNow:r,status:i,detail:a,className:o}){return/* @__PURE__ */ (0,A.jsxs)(`section`,{className:M(`ui-timecontrol`,o),"aria-label":w(`時間控制`),children:[/* @__PURE__ */ (0,A.jsx)(`time`,{className:`ui-timecontrol-clock`,dateTime:e.toISOString(),"aria-live":`off`,children:a_.time(e)}),/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-timecontrol-status`,"aria-live":`polite`,children:i}),a?/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-timecontrol-detail`,children:a}):null,/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-timecontrol-actions`,children:[/* @__PURE__ */ (0,A.jsx)(Xp,{onClick:()=>n(!t),children:w(t?`停止回放`:`回放`)}),/* @__PURE__ */ (0,A.jsx)(Xp,{onClick:r,disabled:!t,children:w(`回到現在`)})]})]})}function Lx({label:e,className:t}){return/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-loading`,t),role:`progressbar`,"aria-label":e||w(`載入中`),"aria-busy":`true`,children:/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-loading-drop`})})}function Rx({label:e,hint:t,error:n,id:r,className:i,required:a,disabled:o,...s}){let c=y.useId(),l=r||c,u=n?l+`-err`:t?l+`-hint`:void 0;return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-field`,n&&`has-error`,o&&`is-disabled`,i),children:[/* @__PURE__ */ (0,A.jsx)(T_,{htmlFor:l,required:a,children:e}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-field-box`,children:[/* @__PURE__ */ (0,A.jsx)(`input`,{type:`text`,...s,required:a,disabled:o,id:l,className:`ui-input`,"aria-invalid":n?!0:void 0,"aria-describedby":u}),n?/* @__PURE__ */ (0,A.jsx)(D_,{}):null]}),u?/* @__PURE__ */ (0,A.jsx)(O_,{id:u,error:n,hint:t}):null]})}_t(),yt(),ti(gt,vt);function zx(e){let t=y.useId(),[n,r]=y.useState(``),[i,a]=y.useState(``),[o,s]=y.useState(!1),[c,l]=y.useState(!1),u=e.error||{},d=c&&!n?w(`請輸入帳號`):u.account,f=c&&!i?w(`請輸入密碼`):u.password;function p(t){t.preventDefault(),l(!0),n&&i&&e.onSubmit({account:n,password:i})}return/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-loginpage`,e.className),children:/* @__PURE__ */ (0,A.jsxs)(`form`,{className:`ui-logincard`,onSubmit:p,noValidate:!0,children:[e.brand?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-login-brand`,children:e.brand}):null,/* @__PURE__ */ (0,A.jsx)(`h1`,{className:`ui-login-title`,children:e.title||w(`登入`)}),/* @__PURE__ */ (0,A.jsx)(Rx,{label:w(`帳號`),value:n,onChange:e=>r(e.target.value),placeholder:w(`Email 或帳號`),autoComplete:`username`,error:d}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-field`,f&&`has-error`),children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-login-pwlabel`,children:[/* @__PURE__ */ (0,A.jsx)(T_,{htmlFor:t,children:w(`密碼`)}),e.forgotHref?/* @__PURE__ */ (0,A.jsx)(`a`,{href:e.forgotHref,className:`ui-link`,children:w(`忘記密碼`)}):null]}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-pwfield`,f&&`is-invalid`),children:[/* @__PURE__ */ (0,A.jsx)(`input`,{id:t,className:`ui-pwfield-input`,type:o?`text`:`password`,value:i,autoComplete:`current-password`,"aria-invalid":f?!0:void 0,"aria-describedby":f?t+`-err`:void 0,onChange:e=>a(e.target.value)}),f?/* @__PURE__ */ (0,A.jsx)(D_,{inline:!0}):null,/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-datefield-btn`,"aria-label":w(o?`隱藏密碼`:`顯示密碼`),"aria-pressed":o,onClick:()=>s(!o),children:/* @__PURE__ */ (0,A.jsx)(Y,{name:o?`eye-slash`:`eye`,size:18})})]}),/* @__PURE__ */ (0,A.jsx)(O_,{id:t+`-err`,error:f})]}),/* @__PURE__ */ (0,A.jsx)(Xp,{variant:`primary`,type:`submit`,loading:e.loading,className:`ui-login-submit`,children:w(`登入`)})]})})}function Bx(e){let t=y.useRef(!0);t.current&&(t.current=!1,e())}function Vx(e,t,n,r,i,a,o,s,c,l=2){let u=Fs(n.current,{event:e,orientation:r,loopFocus:i,rtl:a,cols:l,disabledIndices:o,minIndex:s,maxIndex:c,prevIndex:t>c?s:t,stopEvent:!0});return As(n.current,u)?void 0:u}let Hx=/*#__PURE__*/ y.createContext(void 0),Ux=/*#__PURE__*/ y.createContext(void 0),Wx=/*#__PURE__*/ y.createContext(void 0),Gx=/*#__PURE__*/ y.createContext(!1),Kx=/*#__PURE__*/ y.createContext(``);function qx(){let e=y.useContext(Hx);if(!e)throw Error(Pi(22));return e}function Jx(){let e=y.useContext(Ux);if(!e)throw Error(Pi(23));return e}function Yx(){let e=y.useContext(Wx);if(!e)throw Error(Pi(24));return e}function Xx(){return y.useContext(Kx)}function Zx(){return y.useContext(Gx)}function Qx(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}let $x=(e,t)=>Object.is(e,t);function eS(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function tS(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!Qx(e,t,(e,t)=>eS(e,t,n)):e!==t}function nS(e,t,n){return e?e.some(e=>e!==void 0&&eS(t,e,n)):!1}function rS(e,t,n){return e?e.findIndex(e=>e!==void 0&&eS(e,t,n)):-1}function iS(e,t){if(t!==$x)return n=>nS(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function aS(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(iS(t,n)):rS(e,t,n);return i===-1?null:i}function oS(e,t,n,r,i,a){return nS(r,t,i)?a!=null&&e>a&&nS(r,n[a],i)?a:e:e===a?aS(n,r,i,!0):a}function sS(e,t,n){return e.filter(e=>!eS(t,e,n))}let cS={id:e=>e.id,labelId:e=>e.labelId,items:e=>e.items,selectedValue:e=>e.selectedValue,hasSelectionChips:e=>{let t=e.selectedValue;return Array.isArray(t)&&t.length>0},hasSelectedValue:e=>{let{selectedValue:t,selectionMode:n}=e;return t==null?!1:n===`multiple`&&Array.isArray(t)?t.length>0:!0},hasNullItemLabel:(e,t)=>t?Dg(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMounted:e=>e.forceMounted,inline:e=>e.inline,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(e=>eS(t,e,n)):eS(t,r,n)},transitionStatus:e=>e.transitionStatus,popupProps:e=>e.popupProps,listProps:e=>e.listProps,inputProps:e=>e.inputProps,triggerProps:e=>e.triggerProps,itemRoot:e=>e.itemRoot,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupId:e=>e.popupId,triggerElement:e=>e.triggerElement,inputElement:e=>e.inputElement,inputGroupElement:e=>e.inputGroupElement,popupSide:e=>e.popupSide,openMethod:e=>e.openMethod,inputInsidePopup:e=>e.inputInsidePopup,inputOwnsFormValue:e=>e.inputOwnsFormValue,selectionMode:e=>e.selectionMode,name:e=>e.name,form:e=>e.form,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,grid:e=>e.grid,virtualized:e=>e.virtualized,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,modal:e=>e.modal,autoHighlight:e=>e.autoHighlight},lS={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},uS={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},dS={disabled:!1,...uS},fS={valid(e){return e===null?null:e?{"data-valid":``}:{"data-invalid":``}}},pS={invalid:void 0,name:void 0,validityData:{state:lS,errors:[],error:``,value:``,initialValue:null},setValidityData:Ai,disabled:void 0,setTouched:Ai,setDirty:Ai,setFilled:Ai,setFocused:Ai,focusOwnerRef:{current:void 0},validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:dS,registerFieldControl:Ai,validation:{getValidationProps:(e,t=Mi)=>t,inputRef:{current:null},registeredInputs:/* @__PURE__ */ new Map,registerInput:Ai,getInputControl:()=>null,commit:async()=>{},change:Ai}},mS=/*#__PURE__*/ y.createContext(pS);function hS(e=!0){let t=y.useContext(mS);if(t.setValidityData===Ai&&!e)throw Error(Pi(28));return t}function gS(e,t,n,r,i=!0,a){let{registerFieldControl:o}=hS(),s=Si(()=>Symbol());X(()=>{let c=s.current;i?o(c,{controlRef:e,getValue:r,id:t,name:a,value:n}):o(c,void 0)},[e,i,r,t,a,o,s,n]),X(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}let _S=/*#__PURE__*/ y.createContext({elementRef:{current:null},formRef:{current:{fields:/* @__PURE__ */ new Map}},errors:{},clearErrors:Ai,validationMode:`onSubmit`,submitCountRef:{current:0}});function vS(){return y.useContext(_S)}let yS=/*#__PURE__*/ y.createContext({controlId:void 0,registerControlId:Ai,resetControlId:Ai,labelId:void 0,setLabelId:Ai,messageIds:[],setMessageIds:Ai,getDescriptionProps:e=>e});function bS(){return y.useContext(yS)}function xS(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=bS(),o=_f(),s=Si(()=>Symbol()),c=y.useRef(!1),l=y.useRef(!1),u=$(()=>{c.current&&i!==Ai&&(c.current=!1,i(s.current,void 0))});return X(()=>{if(!n||i===Ai){u();return}let e;if(t!==void 0)l.current=!0,e=t;else if(l.current)e=o;else{a();return}e===void 0?u():(c.current=!0,i(s.current,e))},[t,n,i,a,o,s,u]),X(()=>u,[u]),(n?r:void 0)??t??o}function SS(e){return e==null?void 0:`${e}-popup`}function CS(e,t){return(n,r)=>n!=null&&e.contains(n,r,t)}let wS=jg;function TS(e,t=!1){let{overflowY:n}=Ea(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}let ES=Symbol(`none`),DS={value:ES,index:-1};function OS(e,t,n){let r=e.get(t);if(r!==void 0||n===$x)return r;for(let[r,i]of e)if(eS(r,t,n))return i}function kS(e){let{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:i,onSelectedValueChange:a,defaultInputValue:o,inputValue:s,open:c,defaultOpen:l=!1,selectionMode:u,onItemHighlighted:d,name:f,form:p,disabled:m=!1,readOnly:h=!1,required:g=!1,inputRef:_,grid:v=!1,items:b,filteredItems:x,filter:S,filterQuery:C,openOnInputClick:w=!0,autoHighlight:T=!1,keepHighlight:E=!1,highlightItemOnHover:D=!0,loopFocus:O=!0,itemToStringLabel:k,itemToStringValue:j,isItemEqualToValue:M=$x,virtualized:N=!1,inline:P=!1,fillInputOnItemPress:F=!0,modal:I=!1,limit:L=-1,autoComplete:R=`list`,formAutoComplete:z,locale:B,submitOnItemClick:V=!1}=e,{clearErrors:H}=vS(),{setDirty:U,validityData:ee,setFilled:te,name:ne,disabled:W,setTouched:re,setFocused:ie,validationMode:G,validation:K}=hS(),q=jf(),ae=xS({id:t}),oe=wS({locale:B}),se=Array.isArray(b)?null:b;if(se&&typeof se.label!=`function`)throw Error(Pi(100));let ce=se?se.data:b,le=se?.value,J=le?void 0:ce,ue=y.useMemo(()=>{if(!x||!le)return;let e=Eg(x),t=e.map(le),n;return{values:t,findItem(r,i){if(!n){n=/* @__PURE__ */ new Map;for(let r=0;r<t.length;r+=1)n.has(t[r])||n.set(t[r],e[r])}return OS(n,r,i)}}},[x,le]),de=y.useMemo(()=>se?e=>se.label(e,M,e=>{let t=ue?.findItem(e,M);return t==null?Og(e,k):se.itemLabel(t)}):k,[se,k,ue,M]),fe=y.useMemo(()=>se?Object.assign(e=>se.itemLabel(e),{selected:e=>Og(e,de)}):k,[se,de,k]);function pe(e){return Og(e,de)}let[me,he]=y.useState(!1),[ge,_e]=y.useState(null),ve=y.useRef(ge),ye=y.useRef([]),be=y.useRef([]),xe=y.useRef(null),Se=y.useRef(null),Ce=y.useRef(null),we=y.useRef(null),Te=y.useRef(null),Ee=y.useRef(!1),De=y.useRef(null),Oe=y.useRef(null),ke=y.useRef(null),Ae=y.useRef(DS),je=y.useRef(null),Me=y.useRef([]),Ne=y.useRef(null),Pe=W||m,Fe=ne??f,Ie=u===`multiple`,Le=u===`single`,Re=s!==void 0||o!==void 0,ze=ce!==void 0,Be=x!==void 0,Ve;Ve=T===`always`?`always`:T?`input-change`:!1;let[He,Ue]=Wm({controlled:i,default:Ie?r??ji:r,name:`Combobox`,state:`selectedValue`}),We=y.useMemo(()=>S===null?()=>!0:S===void 0?CS(oe,fe):S,[S,oe,fe]),Ge=Si(()=>Re?o??``:Le?pe(He):``).current,[Ke,qe]=Wm({controlled:s,default:Ge,name:`Combobox`,state:`inputValue`}),[Je,Ye]=Wm({controlled:c,default:l,name:`Combobox`,state:`open`}),Xe=Tg(ce),Ze=!Je&&ge!==null?ge:String(Ke).trim(),Qe=Le?pe(He):``,$e=Le&&!me&&Ze!==``&&Qe.length===Ze.length&&oe.contains(Qe,Ze),et=$e?``:C??Ze,tt=ze&&Be&&$e&&(!se||se.hasValue(He,M)),nt=y.useMemo(()=>ce?Eg(ce):ji,[ce]),rt=y.useMemo(()=>{if(x&&!tt)return x;if(!ce)return ji;if(Xe){let e=ce,t=[],n=0;for(let r of e){if(L>-1&&n>=L)break;let e=L>-1?L-n:1/0,i=et===``?r.items.slice(0,e):[];if(et!==``)for(let t of r.items){if(i.length>=e)break;We(t,et,fe)&&i.push(t)}if(i.length>0){let e={...r,items:i};t.push(e),n+=i.length}}return t}if(et===``)return L>-1?nt.slice(0,L):nt;let e=[];for(let t of nt){if(L>-1&&e.length>=L)break;We(t,et,fe)&&e.push(t)}return e},[x,tt,ce,Xe,et,L,We,fe,nt]),it=y.useMemo(()=>{if(ue&&rt===x)return ue.values;let e=Eg(rt);return le?e.map(e=>le(e)):e},[rt,x,ue,le]),at=Si(()=>{let e=null;return P&&Je&&ze&&u!==`none`&&(e=aS(it,He,M,Ie)),new Du({id:ae,labelId:void 0,selectedValue:He,open:Je,items:J,selectionMode:u,name:Fe,form:p,disabled:Pe,readOnly:h,required:g,grid:v,virtualized:N,openOnInputClick:w,itemToStringLabel:de,isItemEqualToValue:M,modal:I,autoHighlight:Ve,submitOnItemClick:V,hasInputValue:Re,mounted:!1,forceMounted:!1,transitionStatus:`idle`,inline:P,activeIndex:null,selectedIndex:e,popupProps:{},listProps:{},inputProps:{},triggerProps:{},itemRoot:{props:Mi,id:ae,selectionMode:u,disabled:Pe,readOnly:h,isItemEqualToValue:M},positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:u===`none`},{onOpenChangeComplete:Ai,setOpen:Ai,setInputValue:Ai,setSelectedValue:Ai,setIndices:Ai,handleSelection:Ai,forceMount:Ai,requestSubmit:Ai,listRef:ye,labelsRef:be,popupRef:xe,emptyRef:Te,inputRef:Se,startDismissRef:Ce,endDismissRef:we,chipsContainerRef:De,clearRef:Oe,valuesRef:Me,pointerDownItemRef:Ne,selectionEventRef:ke},cS)}).current,ot=u===`none`?Ke:He,st=y.useMemo(()=>u===`none`?ot:Array.isArray(He)?He.map(e=>kg(e,j)):kg(He,j),[ot,j,u,He]),ct=$(d),lt=$(n),ut=at.useState(`activeIndex`),dt=at.useState(`selectedIndex`),ft=at.useState(`positionerElement`),pt=at.useState(`listElement`),mt=at.useState(`triggerElement`),ht=at.useState(`inputElement`),gt=at.useState(`inputGroupElement`),_t=at.useState(`inline`),vt=at.useState(`inputInsidePopup`),yt=at.useState(`inputOwnsFormValue`),bt=Le&&!vt&&Ke===Qe,xt=Vo(mt),{openMethod:St,triggerProps:Ct}=qp(Je),wt=$(()=>st);gS(vt?xt:Se,ae,ot,wt,!Pe,f);let Tt=$(()=>{ce?be.current=it.map(pe):at.set(`forceMounted`,!0)}),Et=$((e,t,n,r)=>{if(t===-1){if(Ae.current===DS)return;Ae.current=DS}else Ae.current={value:e,index:t};ct(e,fo(n,r,{index:t}))}),Dt=$(e=>{let t={};e.activeIndex!==void 0&&(t.activeIndex=e.activeIndex),e.selectedIndex!==void 0&&(t.selectedIndex=e.selectedIndex),at.update(t);let n=e.activeIndex;if(n===void 0)return;let r=e.type||`none`;n===null?Et(void 0,-1,r,e.event):Et(Me.current[n],n,r,e.event)}),Ot=$((t,n)=>{if(e.onInputValueChange?.(t,n),!n.isCanceled){if(Ee.current=n.reason===bo,n.reason===`input-change`){Je&&ge!==null&&_e(null);let e=n.event,r=e.inputType;if(e.type===`compositionend`||r!=null&&r!==``&&r!==`insertReplacementText`){let e=t.trim()!==``;e&&he(!0),je.current={hasQuery:e};let n=at.state.listElement;if(!at.state.virtualized&&n){let e=xe.current;for(let t of Aa(n.firstElementChild??n)){if(!pa(t)||(e?!Z(e,t):t.getAttribute(`role`)===`dialog`))break;if(TS(t)){t.scrollTop=0;break}}}e&&Ve&&at.state.activeIndex==null&&(Je||_t)&&at.set(`activeIndex`,0)}}else n.reason===`input-clear`&&t===``&&at.state.inputInsidePopup&&(je.current={hasQuery:!1,selection:!0});qe(t)}}),kt=$(e=>{let t=!e&&vt&&!_t&&Ke!==``&&(String(Ke).trim()===ge||Ke===Qe);!e&&(t||Ke===``||bt)&&he(!1),_e(null),t&&Ot(``,Q(bo))}),[At,jt]=y.useState(!1),Mt=$((t,n)=>{if(Je===t)return;n.reason===`escape-key`&&ze&&it.length===0&&!Te.current&&n.allowPropagation();let r=n,i=su(r);if(e.onOpenChange?.(t,r),je.current?.hasQuery&&n.reason===`input-change`===n.isCanceled&&(je.current=null),!n.isCanceled&&(t&&ge!==null&&kt(n.reason===yo),!t&&me&&(Le?(_t||_e(Ze),Ze===``&&he(!1)):Ie&&(_t||_e(Ze),vt&&Dt({activeIndex:null}),(!vt||_t)&&Ot(``,Q(bo,n.event,void 0,{isItemPress:n.reason===_o})))),t||jt(i()),Ye(t),!t&&vt&&(n.reason===`focus-out`||n.reason===`outside-press`)&&(re(!0),ie(!1),G===`onBlur`))){let e=u===`none`?Ke:He;K.commit(e)}}),Nt=$((e,t)=>{a?.(e,t),t.isCanceled||(Ue(e),(u===`none`&&xe.current&&F||Le&&!at.state.inputInsidePopup)&&Ot(pe(e),Q(t.reason,t.event)))}),Pt=$((e,t)=>{let n=Pa(e),r=ke.current??e;ke.current=null;let i=Q(_o,r),a=Na(n,`a`)?.getAttribute(`href`);if(a)a.startsWith(`#`)&&Mt(!1,i);else if(Ie){let e=Array.isArray(He)?He:[],n=nS(e,t,M),r=n?sS(e,t,M):[...e,t];if(Nt(r,i),i.isCanceled||!(Se.current&&Se.current.value.trim()!==``))return;if(at.state.inputInsidePopup){Ot(``,Q(bo,i.event,void 0,{isItemPress:!0}));let e=je.current;e&&!n&&(e.toggledValue=t)}else Mt(!1,i)}else{if(Nt(t,i),i.isCanceled)return;Mt(!1,i)}}),Ft=$(()=>{let e=K.inputRef.current?.form??at.state.inputElement?.form;e&&typeof e.requestSubmit==`function`&&e.requestSubmit()}),It=$(()=>{if(lt?.(!1),he(!1),_e(null),Dt(u===`none`?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),Ie&&Se.current&&Se.current.value!==``&&!Ee.current&&Ot(``,Q(bo)),Le){if(at.state.inputInsidePopup)Se.current&&Se.current.value!==``&&Ot(``,Q(bo));else{let e=pe(He);Se.current&&Se.current.value!==e&&Ot(e,Q(e===``?bo:po))}}}),Lt=y.useMemo(()=>_t&&ft?{current:Na(ft,`[role="dialog"]`)}:xe,[_t,ft]),{mounted:Rt,transitionStatus:zt,forceUnmount:Bt}=$l({open:Je,ref:Lt,preventUnmountOnClose:At,setPreventUnmountOnClose:jt,onUnmount:It});y.useImperativeHandle(e.actionsRef,()=>({unmount:Bt,close:()=>Mt(!1,Q(ko))}),[Bt,Mt]),X(function(){let e=ve.current!==null&&ge===null;if(ve.current=ge,Je&&(!e||!ze)||(Je||(Ne.current=null),u===`none`))return;let t=ze?it:Me.current;Dt({selectedIndex:aS(t,He,M,Ie)})},[Je,ge,He,u,Ie,ze,it,M,Dt]),X(()=>{ce&&(Me.current=it,ye.current.length=it.length)},[ce,it]),X(()=>{!Je&&je.current?.hasQuery&&(je.current=null)},[Je]),X(()=>{if(!Je&&_t&&Lt.current){je.current=null;return}let e=ze||Be?it:Me.current,t=je.current;if(t){let n=Je||_t||at.state.positionerElement?.hidden===!1;if(t.hasQuery){let t=Se.current;!Ve||String(Ke).trim()===``||_t&&Ve!==`always`&&(!t||Ma(t.ownerDocument)!==t)?je.current=null:n&&(e[0]!==void 0||!ze&&!Be)&&(at.set(`activeIndex`,0),je.current=null)}else if(String(Ke).trim()===``&&(je.current=null,n)){let e=t.selection;Ve===`always`&&!e&&at.state.selectionMode===`none`&&at.set(`activeIndex`,0),queueMicrotask(()=>{if(!at.state.open&&(!at.state.inline||Lt.current)||Se.current&&Se.current.value.trim()!==``)return;let n=at.state.selectedValue,r=at.state.selectionMode===`multiple`;if(r&&Array.isArray(n)?n.length>0:at.state.selectionMode!==`none`&&n!=null){let e=ze||Be?it:Me.current,i=rS(e,t.toggledValue,at.state.isItemEqualToValue);at.set(`activeIndex`,i===-1?aS(e,n,at.state.isItemEqualToValue,r):i)}else e?at.set(`activeIndex`,null):Ve===`always`&&at.set(`activeIndex`,0)})}}if(!Je&&!_t)return;let n=at.state.activeIndex;if(n==null){if(Ve===`always`&&e.length>0){at.set(`activeIndex`,0);return}Et(void 0,-1,po);return}if(n>=e.length){Et(void 0,-1,po),at.set(`activeIndex`,null);return}let r=e[n],i=Ae.current.value,a=i!==ES&&eS(r,i,at.state.isItemEqualToValue);Ae.current.index===n&&a||Et(r,n,po)},[ut,Ve,Et,Be,ze,it,_t,Je,Lt,at,Ke]),X(()=>{te(u===`none`?String(Ke)!==``:Ie?Array.isArray(He)&&He.length>0:He!=null)},[te,u,Ke,He,Ie]),y.useEffect(()=>{ze&&Ve&&it.length===0&&Dt({activeIndex:null})},[ze,Ve,it.length,Dt]);function Vt(){Je&&Ze!==``&&Ze!==String(Ge)&&!bt&&he(!0)}function Ht(){Je&&ge!==null&&kt(!1)}let Ut=!1;function Wt(){!Ut&&Ke!==Qe&&(Ut=!0,Ot(Qe,Q(po)))}function Gt(){u!==`none`&&(H(Fe),U(tS(He,ee.initialValue,M)),K.change(He),Le&&!Re&&!vt&&Wt())}function Kt(){Le&&!Re&&!vt&&!me&&Wt()}function qt(){u===`none`&&(H(Fe),U(Ke!==ee.initialValue),K.change(Ke))}Gp(Ze,Vt),Gp(Je,Ht),Gp(He,Gt),Gp(Qe,Kt),Gp(ce,Kt),Gp(Ke,qt);let Jt=Ru({open:_t?!0:Je,onOpenChange:Mt,elements:{reference:vt?mt:ht,floating:ft}}),Yt=v?`grid`:`listbox`,Xt=Je||_t,Zt=Xt?`true`:`false`,Qt=y.useMemo(()=>{let e=ht?.tagName===`INPUT`,t=ht==null||e,n=t||Xt,r=t?{autoComplete:`off`,spellCheck:`false`,autoCorrect:`off`,autoCapitalize:`none`}:{};return n&&(r.role=`combobox`,r[`aria-expanded`]=Zt,r[`aria-haspopup`]=Yt,r[`aria-controls`]=Xt?pt?.id:void 0,r[`aria-autocomplete`]=h?`none`:R),{reference:r,floating:{role:`presentation`}}},[ht,Xt,Zt,Yt,pt?.id,R,h]),$t=kl(Jt,{enabled:!Pe&&w,event:`mousedown-only`,toggle:!1,touchOpenDelay:vt?0:100,reason:xo}),en=Fl(Jt,{enabled:!Pe&&!_t,outsidePressEvent:{mouse:`sloppy`,touch:`intentional`},bubbles:_t?!0:void 0,outsidePress(e){let t=Pa(e);return!Z(mt,t)&&!Z(Oe.current,t)&&!Z(De.current,t)&&!Z(gt,t)}}),tn=td(Jt,{enabled:!Pe,id:ae,listRef:ye,activeIndex:ut,selectedIndex:dt,virtual:!0,loopFocus:O,allowEscape:O&&!Ve,focusItemOnOpen:me||u===`none`&&!Ve?!1:`auto`,focusItemOnHover:D,resetOnPointerLeave:!E,orientation:v?`horizontal`:void 0,rtl:q===`rtl`,disabledIndices:ji,grid:v?Vx:void 0,onNavigate(e,t){(t||Je||_t&&e===null)&&zt!==`ending`&&Dt({activeIndex:e,type:Yh(t),event:t?.nativeEvent})}}),nn=y.useMemo(()=>Fc(tn.reference,{onKeyDown(e){v&&at.state.activeIndex==null&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&e.preventBaseUIHandler()}},en.reference,$t.reference,Qt.reference),[tn.reference,en.reference,$t.reference,Qt.reference,v,at]),rn=y.useMemo(()=>Fc(eu,en.floating),[en.floating]),an=y.useMemo(()=>Fc(tn.floating,Qt.floating),[tn.floating,Qt.floating]),on=y.useMemo(()=>{let e=tn.item;return{props:e?{...e,onFocus:void 0}:Mi,id:ae,selectionMode:u,disabled:Pe,readOnly:h,isItemEqualToValue:M}},[tn.item,ae,u,Pe,h,M]);at.useContextCallback(`setOpen`,Mt),at.useContextCallback(`setInputValue`,Ot),at.useContextCallback(`setSelectedValue`,Nt),at.useContextCallback(`setIndices`,Dt),at.useContextCallback(`handleSelection`,Pt),at.useContextCallback(`forceMount`,Tt),at.useContextCallback(`requestSubmit`,Ft),at.useContextCallback(`onOpenChangeComplete`,n),Bx(()=>{at.update({inline:P,popupProps:rn,listProps:an,inputProps:nn,triggerProps:Ct,itemRoot:on})});let sn={id:ae,selectedValue:He,open:Je,mounted:Rt,transitionStatus:zt,items:J,inline:P,popupProps:rn,listProps:an,inputProps:nn,triggerProps:Ct,itemRoot:on,openMethod:St,selectionMode:u,name:Fe,form:p,disabled:Pe,readOnly:h,required:g,grid:v,virtualized:N,openOnInputClick:w,itemToStringLabel:de,modal:I,autoHighlight:Ve,isItemEqualToValue:M,submitOnItemClick:V,hasInputValue:Re};X(()=>{at.update({...sn,inputOwnsFormValue:u===`none`&&(P||!at.state.inputInsidePopup)})},[at,...Object.values(sn)]);let cn=Fo(_,K.inputRef),ln=y.useMemo(()=>({query:Ze,hasItems:ze,filteredItems:rt,flatFilteredValues:it}),[Ze,ze,rt,it]),un=y.useMemo(()=>Array.isArray(ot)?``:kg(ot,j),[ot,j]),dn=Ie&&Array.isArray(He)&&He.length>0,fn=Ie||u===`none`&&yt?void 0:Fe,pn=y.useMemo(()=>!Ie||!Array.isArray(He)||!Fe?null:He.map(e=>{let t=kg(e,j);return/*#__PURE__*/ (0,A.jsx)(`input`,{type:`hidden`,form:p,name:Fe,value:t,disabled:Pe},t)}),[Ie,He,p,Fe,j,Pe]),mn=/*#__PURE__*/ (0,A.jsxs)(y.Fragment,{children:[e.children,/*#__PURE__*/ (0,A.jsx)(`input`,{...K.getValidationProps(Pe,{onFocus(){vt?mt?.focus():(Se.current||mt)?.focus()},onChange(e){if(e.nativeEvent.defaultPrevented||Pe||h)return;let t=e.currentTarget.value,n=t.toLowerCase(),r=Q(po,e.nativeEvent),i=()=>Me.current.findIndex(e=>kg(e,j).toLowerCase()===n||pe(e).toLowerCase()===n);function a(){if(Ie)return;if(u===`none`){Ot(t,r);return}let e=i();e===-1&&(e=Me.current.findIndex((e,t)=>{let r=be.current[t];return r!=null&&r.toLowerCase()===n}));let a=e===-1?void 0:Me.current[e];a!=null&&Nt?.(a,r)}Le&&(Tt(),ce&&i()===-1&&at.set(`forceMounted`,!0)),queueMicrotask(a)}}),id:ae&&fn==null?`${ae}-hidden-input`:void 0,form:p,name:fn,autoComplete:z,disabled:Pe,required:g&&!dn,readOnly:h,value:un,ref:cn,style:fn?es:$o,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),pn]});return/*#__PURE__*/ (0,A.jsx)(Hx.Provider,{value:at,children:/*#__PURE__*/ (0,A.jsx)(Ux.Provider,{value:Jt,children:/*#__PURE__*/ (0,A.jsx)(Gx.Provider,{value:ze,children:/*#__PURE__*/ (0,A.jsx)(Wx.Provider,{value:ln,children:/*#__PURE__*/ (0,A.jsx)(Kx.Provider,{value:Ke,children:mn})})})})})}function AS(e){let{multiple:t=!1,defaultValue:n,value:r,onValueChange:i,autoComplete:a,...o}=e;return/*#__PURE__*/ (0,A.jsx)(kS,{...o,selectionMode:t?`multiple`:`single`,selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:i,formAutoComplete:a})}function jS(e,t){return e??t}let MS={...Ja,...fS,popupSide:e=>e?{"data-popup-side":e}:null,listEmpty:e=>e?{"data-list-empty":``}:null};function NS(e,t,n){let{setFocused:r,focusOwnerRef:i}=hS(),a=$(t=>{(t?!e:i.current===a)&&(i.current=t&&a,n?.(t),r(t))});return X(()=>{let e=t.current;return e?.getRootNode()?.activeElement===e&&a(!0),()=>a(!1)},[e,t,a]),a}let PS=/*#__PURE__*/ y.createContext(void 0);function FS(){return y.useContext(PS)}let IS=/*#__PURE__*/ y.createContext(void 0);function LS(e){let t=y.useContext(IS);if(t===void 0&&!e)throw Error(Pi(21));return t}let RS=/*#__PURE__*/ y.forwardRef(function(e,t){let n=qx(),{buttonRef:r,getButtonProps:i}=pp({native:!1}),a=Fo(t,r);function o(e){n.context.setOpen(!1,Q(vo,e.nativeEvent,e.currentTarget))}let s=i({onClick:o});return/*#__PURE__*/ (0,A.jsx)(`span`,{ref:a,...s,"aria-label":`Dismiss`,tabIndex:void 0,style:es})});function zS(e){let t=e.useState(`mounted`),n=e.useState(`popupSide`),r=e.useState(`positionerElement`);return t&&r?n:null}function BS(){return Yx().filteredItems.length===0}function VS(e){return e===`rtl`?[`ArrowRight`,`ArrowLeft`]:[`ArrowLeft`,`ArrowRight`]}function HS(e,t){let n=e>=t-1?t-2:e;return n>=0?n:void 0}function US(e,t,n){let r=e.context.listRef.current[t];r&&(e.context.selectionEventRef.current=n,r.click(),e.context.selectionEventRef.current=null)}let WS=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,id:a,style:o,...s}=e,{state:c,disabled:l,setTouched:u,validationMode:d,validation:f}=hS(),{labelId:p}=bS(),m=FS(),h=!!LS(!0),g=qx(),_=Xx(),v=jf(),b=g.useState(`required`),x=g.useState(`disabled`),S=g.useState(`readOnly`),C=g.useState(`name`),w=g.useState(`form`),T=g.useState(`selectionMode`),E=g.useState(`autoHighlight`),D=g.useState(`inputProps`),O=g.useState(`triggerProps`),k=g.useState(`open`),j=g.useState(`mounted`),M=g.useState(`selectedValue`),N=g.useState(`id`),P=g.useState(`inline`),F=g.useState(`modal`),I=!!E,L=zS(g),R=l||x||i,z=BS(),B=NS(R,g.context.inputRef),V=h||P,H=!V||F,U=_f(a??(V?void 0:N)),ee=h?uS:c,[te,ne]=y.useState(null),W=y.useRef(!1),re=y.useRef(null);X(()=>{k||(re.current=null)},[k]);let ie=T===`none`&&!h,G=$(e=>{let t=h||g.state.inline;t&&!g.state.hasInputValue&&g.context.setInputValue(``,Q(po)),g.update({inputElement:e,inputInsidePopup:t,inputOwnsFormValue:ie})}),K=h?s:f.getValidationProps(R,s);function q(e){g.context.setIndices({activeIndex:null,selectedIndex:null,type:Yh(e),event:e})}let ae={...ee,open:k,disabled:R,readOnly:S,popupSide:L,listEmpty:z};function oe(e){if(!m)return;let t,n=m.chipsRef.current.length,[r]=VS(v);return e.key===r&&(e.currentTarget.selectionStart??0)===0&&M.length>0&&(e.preventDefault(),t=n>0?n-1:void 0),t}let se=Jc(`input`,e,{state:ae,ref:[t,g.context.inputRef,G],props:[D,O,{value:te??_,"aria-readonly":S||void 0,"aria-required":b||void 0,"aria-labelledby":p,disabled:R,readOnly:S,required:T===`none`?b:void 0,form:w,...ie&&C&&{name:C},id:U,onFocus(){if(B(!0),!P)return;let e=re.current;re.current=null,e!=null&&Object.hasOwn(g.context.valuesRef.current,e)&&g.context.setIndices({activeIndex:e})},onBlur(){u(!0),B(!1);let e=g.state.activeIndex;if(P&&e!==null&&E!==`always`&&(re.current=e,g.context.setIndices({activeIndex:null})),d===`onBlur`){let e=T===`none`?_:M;f.commit(e)}},onCompositionStart(e){Ji||(W.current=!0,ne(e.currentTarget.value))},onCompositionEnd(e){W.current=!1;let t=e.currentTarget.value;ne(null),g.context.setInputValue(t,Q(yo,e.nativeEvent))},onChange(e){let t=e.nativeEvent,n=t.inputType,r=!n||n===`insertReplacementText`,i=W.current||!r;function a(e){!S&&!R&&e&&i&&(g.context.setOpen(!0,Q(yo,t)),I||q(t))}if(W.current){let n=e.currentTarget.value;ne(n),n===``&&!g.state.openOnInputClick&&!g.state.inputInsidePopup&&g.context.setOpen(!1,Q(bo,t));let r=n.trim(),i=I&&r!==``;a(r),k&&g.state.activeIndex!==null&&!i&&q(t);return}let o=Q(yo,t);if(g.context.setInputValue(e.currentTarget.value,o),o.isCanceled)return;let s=e.currentTarget.value===``,c=Q(bo,t);s&&!g.state.inputInsidePopup&&(T===`single`&&g.context.setSelectedValue(null,c),g.state.openOnInputClick||g.context.setOpen(!1,c)),a(e.currentTarget.value.trim()),k&&g.state.activeIndex!==null&&!I&&q(t)},onKeyDown(e){if(e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;if(R||S){S&&e.key===`Enter`&&k&&g.state.activeIndex!==null&&ta(e);return}let t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r=v===`rtl`;if(e.key===`Home`){ta(e);let n=Qi&&r?t.value.length:0;t.setSelectionRange(n,n),t.scrollLeft=0;return}if(e.key===`End`){ta(e);let i=Qi&&r?0:t.value.length;t.setSelectionRange(i,i),t.scrollLeft=r?-n:n;return}if(!j&&e.key===`Escape`){let t=T===`multiple`&&Array.isArray(M)?M.length===0:M===null,n=Q(Co,e.nativeEvent),r=T===`multiple`?[]:null;g.context.setInputValue(``,n),g.context.setSelectedValue(r,n),t||g.state.inline||n.isPropagationAllowed||e.stopPropagation();return}if(m&&e.key===`Backspace`&&t.value===``&&Array.isArray(M)&&M.length>0){let t=m.chipsRef.current.length,n=t>0?t-1:M.length-1,r=M.filter((e,t)=>t!==n);q(e.nativeEvent),g.context.setSelectedValue(r,Q(po,e.nativeEvent));return}let i=oe(e);if(i!==void 0&&m?.chipsRef.current[i]?.focus(),e.which!==229&&e.key===`Enter`&&k){let t=g.state.activeIndex,n=e.nativeEvent;if(t===null){if(P)return;g.context.setOpen(!1,Q(po,n));return}ta(e),US(g,t,n)}}},K],stateAttributesMapping:MS}),ce=h?/*#__PURE__*/ (0,A.jsx)(mS.Provider,{value:pS,children:se}):se;return/*#__PURE__*/ (0,A.jsxs)(y.Fragment,{children:[k&&H&&/*#__PURE__*/ (0,A.jsx)(RS,{ref:g.context.startDismissRef}),ce]})});function GS(e,t,n,r){if(e.baseUIHandlerPrevented)return;let i=Pa(e.nativeEvent),a=fa(i)?i:null;(a===e.currentTarget||!r?.(a)&&!no(a))&&(e.preventDefault(),n||(t.context.inputRef.current?.focus(),t.state.openOnInputClick&&t.context.setOpen(!0,Q(xo,e.nativeEvent))))}let KS=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{state:o}=hS(),s=qx(),c=s.useState(`open`),l=s.useState(`disabled`),u=s.useState(`readOnly`),d=s.useState(`hasSelectedValue`),f=s.useState(`selectionMode`),p=zS(s),m=l,h=BS(),g=f!==`none`&&!d,_={...o,open:c,disabled:m,readOnly:u,popupSide:p,listEmpty:h,placeholder:g};return Jc(`div`,e,{ref:[t,$(e=>{s.set(`inputGroupElement`,e)})],props:[{role:`group`,onMouseDown(e){GS(e,s,m,e=>Z(s.context.chipsContainerRef.current,e))}},a],state:_,stateAttributesMapping:MS})}),qS=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,nativeButton:i=!0,disabled:a=!1,id:o,style:s,...c}=e,{state:l,disabled:u,setTouched:d,validationMode:f,validation:p}=hS(),{labelId:m}=bS(),h=qx(),g=h.useState(`selectionMode`),_=h.useState(`disabled`),v=h.useState(`readOnly`),b=h.useState(`required`),x=h.useState(`positionerElement`),S=h.useState(`listElement`),C=h.useState(`popupId`),w=h.useState(`triggerProps`),T=h.useState(`inputInsidePopup`),E=h.useState(`id`),D=h.useState(`labelId`),O=h.useState(`open`),k=h.useState(`selectedValue`),A=h.useState(`activeIndex`),j=h.useState(`selectedIndex`),M=h.useState(`hasSelectedValue`),N=Jx(),P=Xx(),F=zi(),I=u||_||a,L=BS(),R=zS(h),z=y.useRef(null),B=NS(I,z);xS({id:T?o:void 0});let V=T?o??E:o,H=jS(m,D),U;O&&T?U=C??SS(E):O&&(U=S?.id);let ee=y.useRef(``);function te(e){ee.current=e.pointerType}let{reference:ne}=nd(N,{enabled:!O&&!v&&!_&&g===`single`,listRef:h.context.labelsRef,activeIndex:A,selectedIndex:j,onMatch(e){let t=h.context.valuesRef.current[e];t!==void 0&&h.context.setSelectedValue(t,Q(po))}}),{reference:W}=kl(N,{enabled:!_,event:`mousedown`}),{buttonRef:re,getButtonProps:ie}=pp({native:i,disabled:I}),G={...l,readOnly:v,open:O,disabled:I,popupSide:R,listEmpty:L,placeholder:g!==`none`&&!M};return Jc(`button`,e,{ref:[t,re,z,$(e=>{h.set(`triggerElement`,e)})],state:G,props:[w,W,ne,{id:V,tabIndex:T?0:-1,role:T?`combobox`:void 0,"aria-expanded":O,"aria-haspopup":T?`dialog`:`listbox`,"aria-controls":U,"aria-required":T&&b||void 0,"aria-readonly":T&&v||void 0,"aria-labelledby":H,onPointerDown:te,onPointerEnter:te,onFocus(){B(!0),I||F.start(0,h.context.forceMount)},onBlur(e){if(!Z(x,e.relatedTarget)&&(d(!0),B(!1),f===`onBlur`)){let e=g===`none`?P:k;p.commit(e)}},onMouseDown(e){if(I||(T||N.set(`domReferenceElement`,e.currentTarget),h.context.forceMount(),ee.current!==`touch`&&(h.context.inputRef.current?.focus(),T||e.preventDefault()),O))return;let t=Zo(e.currentTarget);function n(e){let t=h.state.triggerElement;if(!t)return;let n=Pa(e),r=h.state.positionerElement,i=h.state.listElement;Z(t,n)||Z(r,n)||Z(i,n)||sg(e,t)||h.context.setOpen(!1,Q(Do,e))}T&&t.addEventListener(`mouseup`,n,{once:!0})},onKeyDown(e){(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(ta(e),h.context.setOpen(!0,Q(wo,e.nativeEvent)),h.context.inputRef.current?.focus())}},p.getValidationProps(I,c),ie],stateAttributesMapping:MS})}),JS=/*#__PURE__*/ y.createContext(null);function YS(){return y.useContext(JS)}function XS(e){let{children:t}=e,{filteredItems:n}=Yx(),r=YS(),i=r?r.items:n;return/*#__PURE__*/ (0,A.jsx)(y.Fragment,{children:i.map(t)})}let ZS=/*#__PURE__*/ y.forwardRef(function(e,t){var n;let{render:r,className:i,style:a,children:o,...s}=e,c=qx(),l=Jx(),u=!!LS(!0),{filteredItems:d,hasItems:f}=Yx(),p=c.useState(`selectionMode`),m=c.useState(`grid`),h=c.useState(`readOnly`),g=c.useState(`listProps`),_=c.useState(`virtualized`),v=c.useState(`forceMounted`),b=p===`multiple`,x=d.length===0,S=$(e=>{c.set(`positionerElement`,e)}),C=$(e=>{c.set(`listElement`,e)}),w=y.useMemo(()=>typeof o==`function`?n||=/*#__PURE__*/ (0,A.jsx)(XS,{children:o}):o,[o]),T={empty:x},E=l.useState(`floatingId`),D=Jc(`div`,e,{state:T,ref:[t,C,u?null:S],props:[g,{children:w,tabIndex:-1,id:E,role:m?`grid`:`listbox`,"aria-multiselectable":b?`true`:void 0,"aria-readonly":!m&&h?!0:void 0,onKeyDown(e){if(!(c.state.disabled||c.state.readOnly)&&e.key===`Enter`){let t=c.state.activeIndex;if(t==null)return;ta(e),US(c,t,e.nativeEvent)}}},s]});if(_)return D;let O=f&&!v?void 0:c.context.labelsRef;return/*#__PURE__*/ (0,A.jsx)(Oh,{elementsRef:c.context.listRef,labelsRef:O,children:D})}),QS=/*#__PURE__*/ y.createContext(void 0);function $S(){let e=y.useContext(QS);if(e===void 0)throw Error(Pi(20));return e}let eC=/*#__PURE__*/ y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=qx(),a=i.useState(`mounted`),o=i.useState(`forceMounted`);return a||n||o?/*#__PURE__*/ (0,A.jsx)(QS.Provider,{value:n,children:/*#__PURE__*/ (0,A.jsx)(ul,{ref:t,...r})}):null}),tC=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m=!1,collisionAvoidance:h=rl,style:g,..._}=e,v=qx(),y=Jx(),b=$S(),x=v.useState(`modal`),S=v.useState(`open`),C=v.useState(`mounted`),w=v.useState(`openMethod`),T=v.useState(`positionerElement`),E=v.useState(`triggerElement`),D=v.useState(`inputElement`),O=v.useState(`inputGroupElement`),k=v.useState(`inputInsidePopup`),j=v.useState(`transitionStatus`),M=BS(),N=Bf({anchor:i??(k?E:O??D),floatingRootContext:y,positionMethod:a,mounted:C,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m,keepMounted:b,collisionAvoidance:h,lazyFlip:!0});Ih(S&&x,w===`touch`,T,E);let P={open:S,side:N.side,align:N.align,anchorHidden:N.anchorHidden,empty:M};X(()=>{v.set(`popupSide`,N.side)},[v,N.side]);let F=$(e=>{v.set(`positionerElement`,e)}),I=Wf(e,P,{styles:N.positionerStyles,transitionStatus:j,props:_,refs:[t,F],hidden:!C,inert:!S});return/*#__PURE__*/ (0,A.jsxs)(IS.Provider,{value:N,children:[C&&x&&/*#__PURE__*/ (0,A.jsx)(Sp,{inert:Jf(!S),cutout:O??D??E}),I]})}),nC={...Ya,...Ba},rC=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=qx(),l=LS(),u=Jx(),d=c.useState(`mounted`),f=c.useState(`open`),p=c.useState(`openMethod`),m=c.useState(`popupProps`),h=c.useState(`transitionStatus`),g=c.useState(`inputInsidePopup`),_=c.useState(`inputElement`),v=c.useState(`modal`),b=c.useState(`id`),x=BS(),S=s.id??(g?SS(b):void 0);X(()=>(c.set(`popupId`,c.context.popupRef.current?.id||S),()=>{c.set(`popupId`,void 0)}),[c,S]),Ql({open:f,ref:c.context.popupRef,onComplete(){f&&c.context.onOpenChangeComplete(!0)}});let C=Jc(`div`,e,{state:{open:f,side:l.side,align:l.align,anchorHidden:l.anchorHidden,transitionStatus:h,empty:x},ref:[t,c.context.popupRef],props:[m,{id:S,role:g?`dialog`:`presentation`,onFocus(e){let t=Pa(e.nativeEvent);p!==`touch`&&(Z(c.state.listElement,t)||t===e.currentTarget)&&c.context.inputRef.current?.focus()}},Uf(h),s],stateAttributesMapping:nC}),w=a===void 0?g?e=>e===`touch`?c.context.popupRef.current:_:!1:a,T;T=o??(g?void 0:!1);let E=!g||v;return/*#__PURE__*/ (0,A.jsx)(Ol,{context:u,disabled:!d,modal:E,openInteractionType:p,initialFocus:w,returnFocus:T,getInsideElements:()=>[c.context.startDismissRef.current,c.context.endDismissRef.current],children:/*#__PURE__*/ (0,A.jsxs)(y.Fragment,{children:[C,E&&/*#__PURE__*/ (0,A.jsx)(RS,{ref:c.context.endDismissRef})]})})}),iC=/*#__PURE__*/ y.createContext(void 0),aC=/*#__PURE__*/ y.createContext(!1);function oC(){return y.useContext(aC)}function sC(e){let{componentProps:t,forwardedRef:n,virtualized:r,indexFromFilter:i}=e,{render:a,className:o,style:s,value:c=null,index:l,disabled:u=!1,nativeButton:d=!1,...f}=t,p=y.useRef(null),m=rh({guess:!0,index:l,textRef:p}),h=qx(),g=oC(),_=Zx(),{props:v,id:x,selectionMode:S,disabled:C,readOnly:w,isItemEqualToValue:T}=h.useState(`itemRoot`),E=C||u,D=S!==`none`,O=l??i??m.index,k=O!==-1,j=h.useState(`isActive`,O),M=h.useState(`isSelected`,c),N=y.useRef(null),P=x!=null&&k?`${x}-${O}`:void 0,F=M&&D;X(()=>{if(!k||!r&&l==null)return;let e=h.context.listRef.current;return e[O]=N.current,()=>{delete e[O]}},[k,r,O,l,h]),X(()=>{if(!k||_)return;let e=h.context.valuesRef.current;return e[O]=c,()=>{delete e[O]}},[k,_,O,c,h]),X(()=>{if(!k||_)return;let e=h.state.selectedValue,t=h.state.selectedIndex;h.state.selectionMode===`multiple`&&Array.isArray(e)?t=oS(O,c,h.context.valuesRef.current,e,T,t):eS(c,e,T)&&(t=O),h.set(`selectedIndex`,t)},[k,_,h,O,c,T]);let{getButtonProps:I,buttonRef:L}=pp({disabled:E,focusableWhenDisabled:!0,native:d,composite:!0}),R={disabled:E,selected:F,highlighted:j};function z(e){function t(){h.context.handleSelection(e,c)}h.state.submitOnItemClick?(b.flushSync(t),h.context.requestSubmit()):t()}let B={id:P,role:g?`gridcell`:`option`,"aria-selected":D?F:void 0,tabIndex:void 0,onPointerDownCapture(e){e.isPrimary&&(h.context.pointerDownItemRef.current=e.currentTarget),e.preventDefault()},onMouseDown(e){e.preventDefault()},onClick(e){E||w||z(e.nativeEvent)},onMouseUp(e){let t=h.context.pointerDownItemRef.current===e.currentTarget;h.context.pointerDownItemRef.current=null,E||w||e.button!==0||t||!j||z(e.nativeEvent)}},V=Jc(`div`,t,{ref:[L,n,m.ref,N],state:R,props:[v,B,f,I]}),H=y.useMemo(()=>({selected:F,textRef:p}),[F,p]);return/*#__PURE__*/ (0,A.jsx)(iC.Provider,{value:H,children:V})}function cC(e){let{componentProps:t,forwardedRef:n}=e,r=qx().useState(`isItemEqualToValue`),{flatFilteredValues:i}=Yx(),a=rS(i,t.value??null,r);return/*#__PURE__*/ (0,A.jsx)(sC,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:a})}let lC=/*#__PURE__*/ y.memo(/*#__PURE__*/ y.forwardRef(function(e,t){let n=qx().useState(`virtualized`);return n&&e.index==null?/*#__PURE__*/ (0,A.jsx)(cC,{componentProps:e,forwardedRef:t}):/*#__PURE__*/ (0,A.jsx)(sC,{componentProps:e,forwardedRef:t,virtualized:n,indexFromFilter:void 0})})),uC=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=qx(),s=o.useState(`hasSelectionChips`),c=y.useRef([]),l=Jc(`div`,e,{ref:[t,o.context.chipsContainerRef],props:[s?{role:`toolbar`}:Mi,{onMouseDown(e){GS(e,o,o.state.disabled)}},a]}),u=y.useMemo(()=>({chipsRef:c}),[]);return/*#__PURE__*/ (0,A.jsx)(PS.Provider,{value:u,children:/*#__PURE__*/ (0,A.jsx)(Oh,{elementsRef:c,children:l})})}),dC=/*#__PURE__*/ y.createContext(void 0);function fC(){let e=y.useContext(dC);if(!e)throw Error(Pi(17));return e}let pC=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=qx(),{chipsRef:s}=FS(),c=jf(),l=o.useState(`disabled`),u=o.useState(`readOnly`),d=o.useState(`selectedValue`),{ref:f,index:p}=rh();function m(e){let t=p,[n,r]=VS(c);return e.key===n?(e.preventDefault(),t=p>0?p-1:void 0):e.key===r?(e.preventDefault(),t=p<s.current.length-1?p+1:void 0):e.key===`Backspace`||e.key===`Delete`?(t=HS(p,d.length),ta(e),b.flushSync(()=>{o.context.setIndices({activeIndex:null,selectedIndex:null,type:To,event:e.nativeEvent}),o.context.setSelectedValue(d.filter((e,t)=>t!==p),Q(po,e.nativeEvent))})):e.key===`Enter`||e.key===` `?(ta(e),t=void 0):e.key===`ArrowDown`||e.key===`ArrowUp`?(ta(e),b.flushSync(()=>{o.context.setOpen(!0,Q(wo,e.nativeEvent))}),t=void 0):e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey||(t=void 0),t}let h=Jc(`div`,e,{ref:[t,f],state:{disabled:l},props:[{tabIndex:-1,"aria-disabled":l||void 0,"aria-readonly":u||void 0,onKeyDown(e){if(l||u)return;let t=m(e);t===void 0?o.context.inputRef.current?.focus():s.current[t]?.focus()}},a]}),g=y.useMemo(()=>({index:p}),[p]);return/*#__PURE__*/ (0,A.jsx)(dC.Provider,{value:g,children:h})}),mC=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,nativeButton:a=!0,style:o,...s}=e,c=qx(),{index:l}=fC(),u=c.useState(`disabled`),d=c.useState(`readOnly`),f=c.useState(`selectedValue`),p=c.useState(`isItemEqualToValue`),m=u||i,{buttonRef:h,getButtonProps:g}=pp({native:a,disabled:m||d,focusableWhenDisabled:!0}),_={disabled:m};function v(e,t){let n=c.state.activeIndex;if(n==null)return;let r=rS(c.context.valuesRef.current,e,p);r!==-1&&n===r&&c.context.setIndices({activeIndex:null,type:Yh(t),event:t})}function y(e){let t=Q(`chip-remove-press`,e.nativeEvent),n=f[l];return v(n,e.nativeEvent),c.context.setSelectedValue(f.filter((e,t)=>t!==l),t),c.context.inputRef.current?.focus(),t}return Jc(`button`,e,{ref:[t,h],state:_,props:[{tabIndex:-1,onMouseDown(e){e.preventDefault()},onClick(e){y(e).isPropagationAllowed||e.stopPropagation()},onKeyDown(e){e.key!==`Enter`&&e.key!==` `||y(e).isPropagationAllowed||ta(e)}},s,g]})}),hC=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,{filteredItems:s}=Yx(),c=qx(),l=Ng(),u=s.length===0?a:null;return Jc(`div`,e,{ref:[t,c.context.emptyRef,l],props:[{children:u,role:`status`,"aria-live":`polite`,"aria-atomic":!0},o]})});ir(),ti(rr);let gC=`\0create:`;function _C({label:e,options:t,value:n,onChange:r,creatable:i,maxChips:a=2,placeholder:o,emptyText:s,error:c,className:l}){let u=y.useId(),[d,f]=y.useState(``),p=y.useMemo(()=>new Map(t.map(e=>[e.value,e.label])),[t]),m=e=>e.startsWith(gC)?w(`新增「{q}」`,{q:e.slice(8)}):p.get(e)??e,h=d.trim(),g=t.some(e=>e.label===h)||n.includes(h),_=[...t.map(e=>e.value),...n.filter(e=>!p.has(e)),...i&&h&&!g?[gC+h]:[]],v=n.slice(0,a),b=n.length-v.length;return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-field`,c&&`has-error`,l),children:[e?/* @__PURE__ */ (0,A.jsx)(T_,{htmlFor:u,children:e}):null,/* @__PURE__ */ (0,A.jsxs)(AS,{multiple:!0,autoHighlight:!0,items:_,value:n,inputValue:d,onInputValueChange:f,itemToStringLabel:m,onValueChange:e=>{r(e.map(e=>e.startsWith(gC)?e.slice(8):e)),f(``)},children:[/* @__PURE__ */ (0,A.jsxs)(KS,{className:M(`ui-ms`,c&&`is-invalid`),children:[/* @__PURE__ */ (0,A.jsxs)(uC,{className:`ui-ms-chips`,children:[v.map(e=>/* @__PURE__ */ (0,A.jsxs)(pC,{className:`ui-chip`,"aria-label":m(e),children:[m(e),/* @__PURE__ */ (0,A.jsx)(mC,{className:`ui-chip-x`,"aria-label":w(`移除 {name}`,{name:m(e)}),children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`,size:12})})]},e)),b>0?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-chip-more`,title:n.slice(a).map(m).join(`、`),children:`+`+b}):null,/* @__PURE__ */ (0,A.jsx)(WS,{id:u,className:`ui-ms-input`,"aria-invalid":c?!0:void 0,"aria-describedby":c?u+`-err`:void 0,placeholder:n.length?``:o||w(`搜尋`),onKeyDown:e=>{e.key===`Backspace`&&!d&&n.length&&(e.preventBaseUIHandler(),r(n.slice(0,-1)))}})]}),c?/* @__PURE__ */ (0,A.jsx)(D_,{inline:!0}):null]}),/* @__PURE__ */ (0,A.jsx)(eC,{children:/* @__PURE__ */ (0,A.jsx)(tC,{className:`ui-float is-match`,align:`start`,sideOffset:6,children:/* @__PURE__ */ (0,A.jsxs)(rC,{className:`ui-select-menu ui-ms-menu`,children:[/* @__PURE__ */ (0,A.jsx)(hC,{className:`ui-select-empty`,children:s||w(`找不到符合的選項`)}),/* @__PURE__ */ (0,A.jsx)(ZS,{children:e=>e.startsWith(gC)?/* @__PURE__ */ (0,A.jsx)(lC,{value:e,className:`ui-select-opt ui-ms-create`,children:m(e)},e):/* @__PURE__ */ (0,A.jsxs)(lC,{value:e,className:M(`ui-select-opt`,`ui-ms-opt`,n.includes(e)&&`is-on`),children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-check-box`,n.includes(e)&&`is-on`),"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(E_,{v:n.includes(e)})}),/* @__PURE__ */ (0,A.jsx)(`span`,{children:m(e)})]},e)})]})})})]}),/* @__PURE__ */ (0,A.jsx)(O_,{id:u+`-err`,error:c})]})}De(),ti(Ee);function vC({items:e,onOpen:t,onReadAll:n,emptyText:r}){let[i,a]=y.useState(!1),o=e.filter(e=>!e.read).length,s=[];for(let t of e){let e=t.group||``,n=s[s.length-1];!n||n.title!==e?s.push({title:e,items:[t]}):n.items.push(t)}return/* @__PURE__ */ (0,A.jsxs)(bv,{open:i,onOpenChange:a,align:`end`,sideOffset:8,className:`ui-noti`,"aria-label":w(`通知`),trigger:/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-iconbtn`,`ui-bell`,i&&`is-open`),"aria-label":o?w(`通知,{n} 則未讀`,{n:o}):w(`通知`),children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`bell`}),o?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-badge-count`,"aria-hidden":`true`,children:o>99?`99+`:o}):null]}),children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-noti-head`,children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-noti-title`,children:w(`通知`)}),o&&n?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-noti-readall`,onClick:n,children:w(`全部標為已讀`)}):null]}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-noti-list`,children:e.length?s.map((e,n)=>/* @__PURE__ */ (0,A.jsxs)(y.Fragment,{children:[e.title?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-noti-group`,children:e.title}):null,e.items.map(e=>/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-noti-item`,!e.read&&`is-unread`),onClick:()=>t?.(e),children:[e.read?null:/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-noti-dot`,"aria-hidden":`true`}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:w(`未讀`)+w(`,`)})]}),/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-noti-text`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-noti-t`,children:e.title}),e.body?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-noti-b`,children:e.body}):null,e.time?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-noti-time`,children:e.time}):null]})]},e.id))]},n)):/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-noti-empty`,children:r||w(`沒有通知`)})})]})}function yC({label:e,icon:t,count:n,title:r,side:i=`bottom`,align:a=`end`,children:o,triggerClassName:s}){let[c,l]=y.useState(!1);return/* @__PURE__ */ (0,A.jsxs)(bv,{open:c,onOpenChange:l,openOnHover:!0,side:i,align:a,sideOffset:10,className:`ui-popover`,"aria-label":r?void 0:e,trigger:/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-btn`,`ui-btn-secondary`,s),children:[t?/* @__PURE__ */ (0,A.jsx)(fi,{icon:t}):null,e,n?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-pop-count`,children:n}):null]}),children:[/* @__PURE__ */ (0,A.jsx)(_v,{className:`ui-popover-arrow`}),r?/* @__PURE__ */ (0,A.jsx)(vv,{className:`ui-popover-title`,children:r}):null,/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-popover-body`,children:typeof o==`function`?o(()=>l(!1)):o})]})}function bC({value:e,label:t,size:n=72,className:r}){let i=(n-8)/2,a=2*Math.PI*i,o=Math.max(0,Math.min(100,e||0)),s=u_(o,900),c=n/2;return/* @__PURE__ */ (0,A.jsxs)(`svg`,{className:M(`ui-ring`,r),width:n,height:n,viewBox:`0 0 ${n} ${n}`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(o),"aria-label":t,children:[/* @__PURE__ */ (0,A.jsx)(`circle`,{cx:c,cy:c,r:i,className:`ui-ring-track`,strokeWidth:8}),/* @__PURE__ */ (0,A.jsx)(`circle`,{cx:c,cy:c,r:i,className:`ui-ring-fill`,strokeWidth:8,strokeDasharray:`${(a*o/100*s).toFixed(1)} ${a.toFixed(1)}`,transform:`rotate(-90 ${c} ${c})`}),/* @__PURE__ */ (0,A.jsx)(`text`,{x:c,y:c+5,textAnchor:`middle`,className:`ui-ring-text`,children:Math.round(o*s)+`%`})]})}je(),ti(Ae);let xC={live:`即時`,stale:`已過期`,offline:`離線`};function SC({project:e,status:t=`live`,statusLabel:n,options:r=[],value:i,onChange:a,footer:o,className:s}){let c=xC[t]?t:`live`,l=n||w(xC[c]),u=`${e} · ${l}`,d=/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-projsw-dot`,"aria-hidden":`true`}),/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-projsw-text`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-projsw-name`,children:e}),/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-projsw-status`,children:[` · `,l]})]})]});return!r.length||!a?/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-projsw`,`is-`+c,`is-static`,s),role:`status`,"aria-label":u,title:u,children:d}):/* @__PURE__ */ (0,A.jsxs)(ig,{children:[/* @__PURE__ */ (0,A.jsxs)(mg,{className:M(`ui-projsw`,`is-`+c,s),"aria-label":w(`切換專案,目前是 {name}`,{name:u}),title:u,children:[d,/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-down`,size:14,className:`ui-projsw-caret`})]}),/* @__PURE__ */ (0,A.jsx)(Dh,{children:/* @__PURE__ */ (0,A.jsx)(Lh,{className:`ui-float`,side:`bottom`,align:`end`,sideOffset:6,children:/* @__PURE__ */ (0,A.jsxs)(wh,{className:`ui-projsw-pop`,"aria-label":w(`切換專案`),children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-projsw-title`,children:w(`切換專案`)}),/* @__PURE__ */ (0,A.jsx)(Vh,{value:i,onValueChange:e=>e!==i&&a(e),children:r.map(e=>/* @__PURE__ */ (0,A.jsxs)(Gh,{value:e.id,closeOnClick:!0,className:M(`ui-projsw-opt`,e.id===i&&`is-on`),children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-projsw-optlabel`,children:e.label}),e.detail?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-projsw-optdetail`,children:e.detail}):null,/* @__PURE__ */ (0,A.jsx)(Kh,{className:`ui-projsw-check`,children:/* @__PURE__ */ (0,A.jsx)(Y,{d:pi,size:16})})]},e.id))}),o?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-projsw-foot`,children:o}):null]})})})]})}function CC({label:e,value:t,onChange:n,options:r,disabled:i,className:a}){let o=y.useRef([]),s=r.map(e=>!(i||e.disabled)),c=r.findIndex(e=>e.value===t),l=c>=0?c:s.indexOf(!0),u=(e,t)=>{for(let i=1;i<=r.length;i++){let a=(e+t*i+r.length)%r.length;if(s[a]){o.current[a]?.focus(),n?.(r[a].value);return}}};return/* @__PURE__ */ (0,A.jsxs)(`div`,{role:`radiogroup`,"aria-label":e,className:M(`ui-radios`,a),children:[e?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-field-label`,children:e}):null,r.map((e,r)=>{let i=t===e.value;return/* @__PURE__ */ (0,A.jsxs)(`button`,{ref:e=>{o.current[r]=e},type:`button`,role:`radio`,"aria-checked":i,tabIndex:r===l?0:-1,disabled:!s[r],className:M(`ui-radio`,i&&`is-on`),onClick:()=>n?.(e.value),onKeyDown:e=>{W(e)||(e.key===`ArrowDown`||e.key===`ArrowRight`?(e.preventDefault(),u(r,1)):(e.key===`ArrowUp`||e.key===`ArrowLeft`)&&(e.preventDefault(),u(r,-1)))},children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-radio-ring`,"aria-hidden":`true`,children:i?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-radio-dot`}):null}),/* @__PURE__ */ (0,A.jsx)(`span`,{children:e.label})]},e.value)})]})}let wC=/*#__PURE__*/ y.createContext(void 0),TC=/*#__PURE__*/ y.createContext(void 0);function EC(){let e=y.useContext(wC);if(e===void 0)throw Error(Pi(60));return e}function DC(){let e=y.useContext(TC);if(e===void 0)throw Error(Pi(61));return e}let OC={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,multiple:e=>e.multiple,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,highlightItemOnHover:e=>e.highlightItemOnHover,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:kg(t,r)!==``},hasNullItemLabel:(e,t)=>t?Dg(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>eS(t,e,n)):eS(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,itemRoot:e=>e.itemRoot,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows};function kC(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}function AC(e,t){return Math.max(0,e-t)}function jC(e,t){if(t<=0)return 0;let n=kC(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}function MC(e){let{id:t,value:n,defaultValue:r=null,onValueChange:i,open:a,defaultOpen:o=!1,onOpenChange:s,name:c,form:l,autoComplete:u,disabled:d=!1,readOnly:f=!1,required:p=!1,modal:m=!0,actionsRef:h,inputRef:g,onOpenChangeComplete:_,items:v,multiple:b=!1,itemToStringLabel:x,itemToStringValue:S,isItemEqualToValue:C=$x,highlightItemOnHover:w=!0,children:T}=e,{clearErrors:E}=vS(),{setDirty:D,setTouched:O,setFocused:k,validityData:j,setFilled:M,name:N,disabled:P,validation:F,validationMode:I}=hS(),L=xS({id:t}),R=P||d,z=N??c,[B,V]=Wm({controlled:n,default:b?r??ji:r,name:`Select`,state:`value`}),[H,U]=Wm({controlled:a,default:o,name:`Select`,state:`open`}),ee=y.useRef([]),te=y.useRef([]),ne=y.useRef(null),W=y.useRef(null),re=y.useRef(0),ie=y.useRef(null),G=y.useRef([]),K=y.useRef(!1),q=y.useRef(null),ae=y.useRef(null),oe=y.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),se=y.useRef(!1),ce=y.useRef(B),{openMethod:le,triggerProps:J}=qp(H),ue=Si(()=>new Du({id:L,labelId:void 0,modal:m,multiple:b,disabled:R,readOnly:f,required:p,highlightItemOnHover:w,itemToStringLabel:x,itemToStringValue:S,isItemEqualToValue:C,value:B,open:H,mounted:H,transitionStatus:void 0,items:v,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:Mi,triggerProps:Mi,itemRoot:{props:Mi,multiple:b,disabled:R,readOnly:f,isItemEqualToValue:C},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:Ai,setOpen:Ai,handleScrollArrowVisibility:Ai,onOpenChangeComplete:Ai,listRef:ee,popupRef:ne,scrollHandlerRef:W,scrollArrowsMountedCountRef:re,valueRef:ie,valuesRef:G,labelsRef:te,typingRef:K,selectionRef:oe,firstItemTextRef:q,selectedItemTextRef:ae,alignItemWithTriggerActiveRef:se,initialValueRef:ce},OC)).current,[de,fe]=y.useState(!1),{mounted:pe,transitionStatus:me,forceUnmount:he}=$l({open:H,ref:ne,preventUnmountOnClose:de,setPreventUnmountOnClose:fe,onUnmount(){ue.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),_?.(!1)}}),ge=ue.useState(`activeIndex`),_e=ue.useState(`selectedIndex`),ve=ue.useState(`triggerElement`),ye=ue.useState(`positionerElement`),be=Yf(le),xe=le??be,Se=y.useMemo(()=>b?``:kg(B,S),[b,B,S]),Ce=y.useMemo(()=>b&&Array.isArray(B)?B.map(e=>kg(e,S)):kg(B,S),[b,B,S]);gS(Vo(ve),L,B,$(()=>Ce),!R,c);let we=b?Array.isArray(B)&&B.length>0:B!=null&&Se!==``;X(()=>{M(we)},[we,M]),X(function(){let e=aS(G.current,B,C,b);e===null&&(ae.current=null),H||ue.set(`selectedIndex`,e)},[b,H,B,C,ue]),Gp(B,()=>{E(z),D(tS(B,j.initialValue,C)),F.change(B)});let Te=$((e,t)=>{let n=t,r=su(n);s?.(e,n),t.isCanceled||(e||fe(r()),U(e),e||t.reason!==`focus-out`&&t.reason!==`outside-press`||(O(!0),k(!1),I===`onBlur`&&F.commit(B)))});y.useImperativeHandle(h,()=>({unmount:he,close:()=>{ue.state.open&&Te(!1,Q(ko))}}),[he,Te,ue]);let Ee=$((e,t)=>{i?.(e,t),t.isCanceled||V(e)}),De=$(e=>{let t=AC(e.scrollHeight,e.clientHeight),n=jC(e.scrollTop,t),r=n>0,i=n<t;ue.set(`scrollUpArrowVisible`,r),ue.set(`scrollDownArrowVisible`,i)}),Oe=Ru({open:H,onOpenChange:Te,elements:{reference:ve,floating:ye}}),ke=kl(Oe,{enabled:!R,event:`mousedown`}),Ae=Fl(Oe),je=td(Oe,{enabled:!R,listRef:ee,activeIndex:ge,selectedIndex:_e,disabledIndices:ji,onNavigate(e){(e!==null||H)&&ue.set(`activeIndex`,e)},focusItemOnHover:w}),Me=nd(Oe,{enabled:!R&&(H||!f&&!b),listRef:te,activeIndex:ge,selectedIndex:_e,disabledIndices:e=>vg(ee.current[e]),onMatch(e){H?ue.set(`activeIndex`,e):Ee(G.current[e],Q(po))},onTyping(e){K.current=e}}),Ne=y.useMemo(()=>Fc(Me.reference,je.reference,Ae.reference,ke.reference,J),[ke.reference,Me.reference,je.reference,Ae.reference,J]),Pe=y.useMemo(()=>Fc(eu,Me.floating,je.floating,Ae.floating),[Me.floating,je.floating,Ae.floating]),Fe=je.item??Mi,Ie=y.useMemo(()=>({props:Fe,multiple:b,disabled:R,readOnly:f,isItemEqualToValue:C}),[Fe,b,R,f,C]);ue.useContextCallback(`setValue`,Ee),ue.useContextCallback(`setOpen`,Te),ue.useContextCallback(`handleScrollArrowVisibility`,De),ue.useContextCallback(`onOpenChangeComplete`,_),Bx(()=>{ue.update({popupProps:Pe,triggerProps:Ne,itemRoot:Ie})}),ue.useSyncedValues({id:L,modal:m,multiple:b,disabled:R,readOnly:f,required:p,highlightItemOnHover:w,value:B,open:H,mounted:pe,transitionStatus:me,popupProps:Pe,triggerProps:Ne,itemRoot:Ie,items:v,itemToStringLabel:x,itemToStringValue:S,isItemEqualToValue:C,openMethod:xe});let Le=Fo(g,F.inputRef),Re=b?void 0:z,ze=y.useMemo(()=>!b||!Array.isArray(B)||!z?null:B.map(e=>{let t=kg(e,S);return/*#__PURE__*/ (0,A.jsx)(`input`,{type:`hidden`,form:l,name:z,value:t,disabled:R},t)}),[b,B,l,z,S,R]);return/*#__PURE__*/ (0,A.jsxs)(wC.Provider,{value:ue,children:[/*#__PURE__*/ (0,A.jsx)(TC.Provider,{value:Oe,children:T}),/*#__PURE__*/ (0,A.jsx)(`input`,{...F.getValidationProps(R,{onFocus(){ue.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||R||f)return;let t=e.currentTarget.value,n=Q(po,e.nativeEvent);function r(){if(b)return;let e=t.toLowerCase(),r=G.current.findIndex(t=>kg(t,S).toLowerCase()===e||Og(t,x).toLowerCase()===e);r===-1&&(r=G.current.findIndex((t,n)=>{let r=te.current[n];return r!=null&&r.toLowerCase()===e}));let i=G.current[r];i!=null&&Ee(i,n)}ue.set(`forceMount`,!0),queueMicrotask(r)}}),id:L&&Re==null?`${L}-hidden-input`:void 0,form:l,name:Re,autoComplete:u,value:Se,disabled:R,required:p&&!(b&&we),readOnly:f,ref:Le,style:z?es:$o,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),ze]})}let NC={...Ja,...fS,popupSide:e=>e?{"data-popup-side":e}:null,value:()=>null},PC=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{setTouched:l,validationMode:u,validation:d,state:f,disabled:p}=hS(),{labelId:m}=bS(),h=EC(),g=h.useState(`readOnly`),_=h.useState(`required`),v=h.useState(`disabled`),b=p||v||a,x=h.useState(`open`),S=h.useState(`mounted`),C=h.useState(`value`),w=h.useState(`triggerProps`),T=h.useState(`positionerElement`),E=h.useState(`listElement`),D=h.useState(`popupSide`),O=h.useState(`id`),k=h.useState(`labelId`),A=h.useState(`hasSelectedValue`),j=S&&T?D:null,M=i??O,N=jS(m,k);xS({id:i});let P=Vo(T),F=y.useRef(null),I=NS(b,F),{getButtonProps:L,buttonRef:R}=pp({disabled:b,native:o}),z=h.useStateSetter(`triggerElement`),B=zi(),V=zi(),H=zi();y.useEffect(()=>{if(x)return H.start(400,()=>{h.context.selectionRef.current.allowUnselectedMouseUp=!0,h.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{H.clear()};h.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},V.clear()},[x,h,V,H]);let U=Fc(w,{id:M,role:`combobox`,"aria-expanded":x,"aria-haspopup":`listbox`,"aria-controls":x?E?.id??ao(T)?.id:void 0,"aria-labelledby":N,"aria-readonly":g||void 0,"aria-required":_||void 0,tabIndex:b?-1:0,onFocus(e){I(!0),x&&h.context.alignItemWithTriggerActiveRef.current&&h.context.setOpen(!1,Q(po,e.nativeEvent)),B.start(0,()=>{h.set(`forceMount`,!0)})},onBlur(e){Z(T,e.relatedTarget)||(l(!0),I(!1),u===`onBlur`&&d.commit(C))},onMouseDown(e){if(x)return;let t=Zo(e.currentTarget);function n(e){if(!F.current)return;let t=e.target;Z(F.current,t)||Z(P.current,t)||sg(e,F.current)||h.context.setOpen(!1,Q(Do,e))}V.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},c,L),ee=d.getValidationProps(b,U);ee.role=`combobox`;let te={...f,open:x,disabled:b,value:C,readOnly:g,popupSide:j,placeholder:!A};return Jc(`button`,e,{ref:[t,F,R,z],state:te,stateAttributesMapping:NC,props:ee})}),FC=/*#__PURE__*/ y.forwardRef(function(e,t){let n=EC(),r=n.useState(`mounted`),i=n.useState(`forceMount`);return r||i?/*#__PURE__*/ (0,A.jsx)(ul,{ref:t,...e}):null}),IC=/*#__PURE__*/ y.createContext(void 0);function LC(){let e=y.useContext(IC);if(!e)throw Error(Pi(59));return e}function RC(e,t){e&&Object.assign(e.style,t)}let zC={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},BC={position:`fixed`},VC=/*#__PURE__*/ y.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m,alignItemWithTrigger:h=!0,collisionAvoidance:g=rl,style:_,...v}=e,b=EC(),x=DC(),S=b.useState(`open`),C=b.useState(`mounted`),w=b.useState(`modal`),T=b.useState(`value`),E=b.useState(`openMethod`),D=b.useState(`positionerElement`),O=b.useState(`triggerElement`),k=b.useState(`isItemEqualToValue`),j=b.useState(`transitionStatus`),M=y.useRef(null),N=y.useRef(null),[P,F]=y.useState(h),I=C&&P&&E!==`touch`;!C&&P!==h&&F(h),y.useImperativeHandle(b.context.alignItemWithTriggerActiveRef,()=>I),Ih((I||w)&&S,E===`touch`,D,O);let L=Bf({anchor:n,floatingRootContext:x,positionMethod:a,mounted:C,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??I,collisionAvoidance:g,keepMounted:!0}),R=I?`none`:L.side,z=I?BC:L.positionerStyles,B={open:S,side:R,align:L.align,anchorHidden:L.anchorHidden};X(()=>{b.set(`popupSide`,L.side)},[b,L.side]);let V=Wf(e,B,{styles:z,transitionStatus:j,props:v,refs:[t,b.useStateSetter(`positionerElement`)],hidden:!C,inert:!S}),H=y.useRef(0),U=$(e=>{if(b.context.valuesRef.current.length===0)return;let t=H.current;H.current=e.size;let n=Q(po);if(t!==0&&!b.state.multiple&&T!==null&&rS(b.context.valuesRef.current,T,k)===-1){let e=b.context.initialValueRef.current,t=e!=null&&rS(b.context.valuesRef.current,e,k)!==-1?e:null;b.context.setValue(t,n),t===null&&(b.set(`selectedIndex`,null),b.context.selectedItemTextRef.current=null)}if(t!==0&&b.state.multiple&&Array.isArray(T)){let e=T.filter(e=>rS(b.context.valuesRef.current,e,k)!==-1);e.length!==T.length&&(b.context.setValue(e,n),e.length===0&&(b.set(`selectedIndex`,null),b.context.selectedItemTextRef.current=null))}if(S&&I){b.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};RC(D,e),RC(b.context.popupRef.current,e)}}),ee=y.useMemo(()=>({...L,side:R,alignItemWithTriggerActive:I,setControlledAlignItemWithTrigger:F,scrollUpArrowRef:M,scrollDownArrowRef:N}),[L,R,I,F]);return/*#__PURE__*/ (0,A.jsx)(Oh,{elementsRef:b.context.listRef,labelsRef:b.context.labelsRef,onMapChange:U,children:/*#__PURE__*/ (0,A.jsxs)(IC.Provider,{value:ee,children:[C&&w&&/*#__PURE__*/ (0,A.jsx)(Sp,{inert:Jf(!S),cutout:O}),V]})})}),HC=`base-ui-disable-scrollbar`,UC={className:HC,getElement(e){return/*#__PURE__*/ (0,A.jsx)(`style`,{nonce:e,href:HC,precedence:`base-ui:low`,children:`.${HC}{scrollbar-width:none}.${HC}::-webkit-scrollbar{display:none}`})}},WC=/*#__PURE__*/ y.createContext(void 0),GC={disableStyleElements:!1};function KC(){return y.useContext(WC)??GC}let qC=`--transform-origin`,JC={...Ya,...Ba},YC=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,s=EC(),c=s.useState(`multiple`),l=s.useState(`readOnly`),u=s.useState(`highlightItemOnHover`),d=DC(),{side:f,align:p,alignItemWithTriggerActive:m,isPositioned:h,setControlledAlignItemWithTrigger:g}=LC(),_=hh(!0)!=null,v=jf(),{nonce:b,disableStyleElements:x}=KC(),S=s.useState(`id`),C=s.useState(`open`),w=s.useState(`openMethod`),T=s.useState(`mounted`),E=s.useState(`popupProps`),D=s.useState(`transitionStatus`),O=s.useState(`triggerElement`),k=s.useState(`positionerElement`),j=s.useState(`listElement`),M=y.useRef(!1),N=y.useRef(!1),P=y.useRef({}),F=Xo(),I=$(e=>{if(!k||!s.context.popupRef.current||!N.current)return;let t=k.style.top===`0px`,n=k.style.bottom===`0px`;if(M.current||!m||!t&&!n){s.context.handleScrollArrowVisibility(e);return}let r=QC(k),i=$C(k.getBoundingClientRect().height,`y`,r),a=Zo(k),o=la(k),c=o.getComputedStyle(k),l=parseFloat(c.marginTop),u=parseFloat(c.marginBottom),d=XC(o.getComputedStyle(s.context.popupRef.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,h=ZC(e),g=null,_=e=>{k.style.height=`${e}px`},v=t?h-p:p,y=Math.min(i+v,f);if(v<=1){let n=kC(v,0,f-i);n>0&&_(i+n),e.scrollTop=t?h:0,f-(i+n)<=1&&(M.current=!0),s.context.handleScrollArrowVisibility(e);return}f-y>1?g=t?1/0:0:n&&p<h&&(g=p-(v-(i+v-f)));let b=Math.ceil(y);if(b!==0&&_(b),g!=null){let t=kC(g,0,ZC(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(M.current=!0),s.context.handleScrollArrowVisibility(e)});y.useImperativeHandle(s.context.scrollHandlerRef,()=>I,[I]),Ql({open:C,ref:s.context.popupRef,onComplete(){C&&s.context.onOpenChangeComplete(!0)}});let L={open:C,transitionStatus:D,side:f,align:p};X(()=>{k&&s.context.popupRef.current&&!Object.keys(P.current).length&&(P.current={top:k.style.top||`0`,left:k.style.left||`0`,right:k.style.right,height:k.style.height,bottom:k.style.bottom,minHeight:k.style.minHeight,maxHeight:k.style.maxHeight,marginTop:k.style.marginTop,marginBottom:k.style.marginBottom})},[s,k]),X(()=>{C||m||(N.current=!1,M.current=!1,RC(k,P.current))},[C,m,k]),X(()=>{let e=s.context.popupRef.current;if(!C||!O||!k||!e||m&&!h||s.state.transitionStatus===`ending`)return;if(N.current=!0,e.style.removeProperty(qC),!m){F.request(()=>s.context.handleScrollArrowVisibility(j||e));return}let t=nw(e);try{let t=s.context.selectedItemTextRef.current;t?.isConnected||(t=!s.select(`hasSelectedValue`)&&s.context.firstItemTextRef.current?.isConnected?s.context.firstItemTextRef.current:null);let n=s.context.valueRef.current,r=la(k),i=r.getComputedStyle(k),a=r.getComputedStyle(e),o=Zo(O),c=QC(O),l=ew(O.getBoundingClientRect(),c),d=ew(k.getBoundingClientRect(),c),f=l.height,p=j||e,m=p.scrollHeight,h=parseFloat(a.borderBottomWidth),_=parseFloat(i.marginTop)||10,y=parseFloat(i.marginBottom)||10,b=parseFloat(i.minHeight)||100,x=XC(a),S=o.documentElement.clientHeight-_-y,C=o.documentElement.clientWidth,w=S-l.bottom+f,T,E=v===`rtl`?l.right-d.width:l.left,D=0;if(t&&n){let e=ew(n.getBoundingClientRect(),c);T=ew(t.getBoundingClientRect(),c),E=d.left+(v===`rtl`?e.right-T.right:e.left-T.left);let r=e.top-l.top+e.height/2;D=T.top-d.top+T.height/2-r}let A=w+D+y+h,N=Math.min(S,A),F=S-_-y,I=A-N,L=C-5;k.style.left=`${kC(E,5,L-d.width)}px`,k.style.height=`${N}px`,k.style.maxHeight=`none`,k.style.marginTop=`${_}px`,k.style.marginBottom=`${y}px`,e.style.height=`100%`;let R=ZC(p),z=I>=R-1;z&&(N=Math.min(S,d.height)-(I-R));let B=l.top<20||l.bottom>S-20||Math.ceil(N)+1<Math.min(m,b),V=(r.visualViewport?.scale??1)!==1&&Zi;if(B||V){RC(k,P.current),g(!1);return}let H=Math.max(b,N);if(z){let e=Math.max(0,S-A);k.style.top=d.height>=F?`0`:`${e}px`,k.style.height=`${N}px`,p.scrollTop=ZC(p)}else k.style.bottom=`0`,p.scrollTop=I;if(T){let t=d.top,n=d.height,r=T.top+T.height/2,i=kC(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(qC,`50% ${i}%`)}(H===S||N>=x)&&(M.current=!0),s.context.handleScrollArrowVisibility(p),u&&s.state.selectedIndex===null&&s.state.activeIndex===null&&s.context.listRef.current[0]!=null&&s.set(`activeIndex`,0)}finally{t()}},[s,C,k,O,m,g,F,j,u,v,h]),y.useEffect(()=>{if(!m||!k||!C)return;let e=la(k);function t(e){s.context.setOpen(!1,Q(`window-resize`,e))}return No(e,`resize`,t)},[s,m,k,C]);let R={...j?{role:`presentation`}:{role:`listbox`,"aria-multiselectable":c||void 0,"aria-readonly":l||void 0,id:`${S}-list`},onKeyDown(e){_&&yp.has(e.key)&&e.stopPropagation()},onScroll(e){j||I(e.currentTarget)},...m&&{style:j?{height:`100%`}:zC},className:!j&&m?UC.className:void 0},z=Jc(`div`,e,{ref:[t,s.context.popupRef],state:L,stateAttributesMapping:JC,props:[E,R,Uf(D),o]});return/*#__PURE__*/ (0,A.jsxs)(y.Fragment,{children:[!x&&UC.getElement(b),/*#__PURE__*/ (0,A.jsx)(Ol,{context:d,modal:!1,disabled:!T,openInteractionType:w,returnFocus:a,restoreFocus:!0,children:z})]})});function XC(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function ZC(e){return AC(e.scrollHeight,e.clientHeight)}function QC(e){return Ud.getScale(e)}function $C(e,t,n){return e/n[t]}function ew(e,t){return Os({x:$C(e.x,`x`,t),y:$C(e.y,`y`,t),width:$C(e.width,`x`,t),height:$C(e.height,`y`,t)})}let tw=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function nw(e){let{style:t}=e,n={};for(let[e,r]of tw)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of tw){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}let rw=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=EC(),s=o.useState(`multiple`),c=o.useState(`readOnly`),{alignItemWithTriggerActive:l}=LC(),u=o.useState(`hasScrollArrows`),d=o.useState(`openMethod`),f={id:`${o.useState(`id`)}-list`,role:`listbox`,"aria-multiselectable":s||void 0,"aria-readonly":c||void 0,onScroll(e){o.context.scrollHandlerRef.current?.(e.currentTarget)},...l&&{style:zC},className:u&&d!==`touch`?UC.className:void 0};return Jc(`div`,e,{ref:[t,o.useStateSetter(`listElement`)],props:[f,a]})}),iw=/*#__PURE__*/ y.createContext(void 0),aw=/*#__PURE__*/ y.memo(/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,u=y.useRef(null),d=rh({guess:!0,label:o,textRef:u}),f=EC(),{props:p,multiple:m,disabled:h,readOnly:g,isItemEqualToValue:_}=f.useState(`itemRoot`),v=h||s,b=f.useState(`isActive`,d.index),x=f.useState(`open`),S=f.useState(`isSelected`,a),C=f.useState(`isSelectedByFocus`,d.index),w=d.index,T=y.useRef(null);X(()=>{let e=f.context.valuesRef.current;return e[w]=a,()=>{delete e[w]}},[w,a,f]),X(()=>{let e=f.state.value,t=f.state.selectedIndex,n=t,r;m&&Array.isArray(e)?(n=oS(w,a,f.context.valuesRef.current,e,_,t),r=n===w,w===t&&!r&&(f.context.selectedItemTextRef.current=null)):(r=e!==void 0&&eS(a,e,_),r&&(n=w)),f.set(`selectedIndex`,n),r&&u.current&&(f.context.selectedItemTextRef.current=u.current)},[w,m,_,f,a]);let E=y.useRef(`mouse`),D=y.useRef(!1),{getButtonProps:O,buttonRef:k}=pp({disabled:v,focusableWhenDisabled:!0,native:c,composite:!0}),j={disabled:v,selected:S,highlighted:b};function M(e){if(h||g)return;let t=f.state.value;if(m){let n=Array.isArray(t)?t:[],r=S?sS(n,a,_):[...n,a];f.context.setValue(r,Q(_o,e))}else f.context.setValue(a,Q(_o,e)),f.context.setOpen(!1,Q(_o,e))}function N(){f.context.selectionRef.current.dragY=0}let P={role:`option`,"aria-selected":S,tabIndex:x&&b?0:-1,onKeyDown(e){f.set(`activeIndex`,w),e.key===` `&&f.context.typingRef.current&&e.preventDefault()},onClick(e){let t=E.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&ra(e.nativeEvent)&&(n!==void 0||b),i=t&&!r&&!D.current;D.current=!1,v||i||M(e.nativeEvent)},onPointerEnter(e){E.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=f.context.selectionRef.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){E.current=e.pointerType,D.current=!0,N()},onMouseUp(){if(N(),v||E.current===`touch`||D.current)return;let e=!f.context.selectionRef.current.allowSelectedMouseUp&&S,t=!f.context.selectionRef.current.allowUnselectedMouseUp&&!S;e||t||(D.current=!0,T.current?.click(),D.current=!1)}},F=Jc(`div`,e,{ref:[k,t,d.ref,T],state:j,props:[p,P,l,O]}),I=y.useMemo(()=>({selected:S,index:w,textRef:u,selectedByFocus:C}),[S,w,u,C]);return/*#__PURE__*/ (0,A.jsx)(iw.Provider,{value:I,children:F})}));je(),qe(),cn(),ti(Ae,Ke,sn);function ow(e){let{label:t,value:n,onChange:r,options:i,searchable:a=i.length>8,placeholder:o,searchPlaceholder:s,required:c,disabled:l,error:u,name:d,className:f}=e,p=y.useId(),m=i.find(e=>e.value===n)??null,h=t?/* @__PURE__ */ (0,A.jsx)(T_,{id:p,required:c,children:t}):null,g=/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(!m&&`is-placeholder`),children:m?m.label:o||w(`請選擇`)}),u?/* @__PURE__ */ (0,A.jsx)(D_,{inline:!0}):null,/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-down`,size:16,className:`ui-select-chev`})]}),_=p+`-err`,v=/* @__PURE__ */ (0,A.jsx)(O_,{id:_,error:u}),b=(e,t)=>/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{children:e.label}),t?/* @__PURE__ */ (0,A.jsx)(Y,{name:`check`,size:16}):null]}),x={"aria-labelledby":t?p:void 0,"aria-label":t?void 0:e[`aria-label`],"aria-invalid":u?!0:void 0,"aria-describedby":u?_:void 0},S=M(`ui-select-trigger`,u&&`is-invalid`);return a?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-select`,f),children:[h,/* @__PURE__ */ (0,A.jsxs)(AS,{items:i,value:m,onValueChange:e=>e&&r?.(e.value),itemToStringLabel:e=>e.label,isItemEqualToValue:(e,t)=>e.value===t.value,disabled:l,required:c,name:d,children:[/* @__PURE__ */ (0,A.jsx)(qS,{className:S,...x,children:g}),/* @__PURE__ */ (0,A.jsx)(eC,{children:/* @__PURE__ */ (0,A.jsx)(tC,{className:`ui-select-positioner`,align:`start`,sideOffset:6,children:/* @__PURE__ */ (0,A.jsxs)(rC,{className:`ui-select-menu`,"aria-label":t||e[`aria-label`],children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-select-search`,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`magnifying-glass`,size:14}),/* @__PURE__ */ (0,A.jsx)(WS,{placeholder:s||w(`搜尋`),"aria-label":s||w(`搜尋`)})]}),/* @__PURE__ */ (0,A.jsx)(hC,{className:`ui-select-empty`,children:w(`找不到符合的選項`)}),/* @__PURE__ */ (0,A.jsx)(ZS,{children:e=>/* @__PURE__ */ (0,A.jsx)(lC,{value:e,disabled:e.disabled,className:M(`ui-select-opt`,e.value===n&&`is-on`),children:b(e,e.value===n)},e.value)})]})})})]}),v]}):/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-select`,f),children:[h,/* @__PURE__ */ (0,A.jsxs)(MC,{items:i,value:n??null,onValueChange:e=>e!=null&&r?.(e),disabled:l,required:c,name:d,children:[/* @__PURE__ */ (0,A.jsx)(PC,{className:S,...x,children:g}),/* @__PURE__ */ (0,A.jsx)(FC,{children:/* @__PURE__ */ (0,A.jsx)(VC,{className:`ui-select-positioner`,alignItemWithTrigger:!1,align:`start`,sideOffset:6,children:/* @__PURE__ */ (0,A.jsx)(YC,{className:`ui-select-menu`,children:/* @__PURE__ */ (0,A.jsx)(rw,{children:i.map(e=>/* @__PURE__ */ (0,A.jsx)(aw,{value:e.value,disabled:e.disabled,className:M(`ui-select-opt`,e.value===n&&`is-on`),children:b(e,e.value===n)},e.value))})})})})]}),v]})}qe(),ti(Ke);function sw({children:e,actionLabel:t,onAction:n}){return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-toast`,role:`status`,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`check`,className:`ui-toast-icon`}),/* @__PURE__ */ (0,A.jsx)(`span`,{children:e}),t?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-toast-action`,onClick:n,children:t}):null]})}function cw({title:e,categories:t,value:n,onChange:r,toast:i,className:a}){let[o,s]=y.useState(n??t[0]?.id),c=n??o,l=t.find(e=>e.id===c)??t[0];return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-settings`,a),children:[e?/* @__PURE__ */ (0,A.jsx)(`h1`,{className:`ui-settings-title`,children:e}):null,/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-settings-body`,children:[/* @__PURE__ */ (0,A.jsx)(`nav`,{className:`ui-settings-nav`,"aria-label":w(`設定分類`),children:t.map(e=>{let t=e.id===c;return/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:M(`ui-settings-cat`,t&&`is-on`),"aria-current":t?`page`:void 0,onClick:()=>{s(e.id),r?.(e.id)},children:e.label},e.id)})}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-settings-content`,children:l?.content})]}),i?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-settings-toast`,children:/* @__PURE__ */ (0,A.jsx)(sw,{children:i})}):null]})}function lw({title:e,description:t,children:n,className:r}){return/* @__PURE__ */ (0,A.jsxs)(`section`,{className:M(`ui-settings-section`,r),children:[e?/* @__PURE__ */ (0,A.jsx)(`h2`,{className:`ui-settings-h`,children:e}):null,t?/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-settings-desc`,children:t}):null,n]})}function uw({width:e=`100%`,height:t=16}){return/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-skel`,style:{width:e,height:t},"aria-hidden":`true`})}rt(),ti(nt);function dw({title:e,before:t,after:n,copyText:r,copyLabel:i,onCopy:a,onCopyError:o,refHref:s,onRef:c,isRef:l,className:u}){let[d,f]=y.useState(!1),p=y.useRef(void 0);y.useEffect(()=>()=>clearTimeout(p.current),[]);let m=()=>{let e=r??n;te(e).then(()=>{f(!0),clearTimeout(p.current),p.current=setTimeout(()=>f(!1),2e3),a?.(e)},()=>o?.())},h=(e,t)=>/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-sug-line is-`+e,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-sug-mark`,"aria-hidden":`true`,children:e===`del`?`−`:`+`}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:w(e===`del`?`原本:`:`改成:`)}),/* @__PURE__ */ (0,A.jsx)(Y_,{className:`ui-sug-text`,text:t,refHref:s,onRef:c,isRef:l})]});return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-sug`,u),children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-sug-head`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-sug-title`,children:e||w(`建議修正`)}),/* @__PURE__ */ (0,A.jsx)(np,{className:M(`ui-sug-copy`,d&&`is-copied`),label:d?w(`已複製`):i||w(`複製修正`),icon:d?pi:`copy`,onClick:m})]}),t==null?null:h(`del`,t),h(`add`,n),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,"aria-live":`polite`,children:d?w(`已複製`):``})]})}function fw({items:e,value:t,onChange:n,label:r,iconOnly:i=!1,className:a}){G(i&&e.some(e=>!e.icon),`SegmentedControl`,`iconOnly 需要每一項都有 icon;沒有圖示的那一項只剩空白。補上 icon,或拿掉 iconOnly 改顯示文字。`);let o=y.useRef([]),s=Math.max(0,e.findIndex(e=>e.id===t)),[c,l]=y.useState(null),[u,d]=y.useState(!0);y.useLayoutEffect(()=>{let e=o.current[s];if(!e)return;let t=()=>l({left:e.offsetLeft,width:e.offsetWidth});t();let n=U(t);return n?.observe(e),()=>n?.disconnect()},[s,e.length]);let f=t=>{t!==s&&e[t]&&(d(t>s),n?.(e[t].id))};return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-seg`,i&&`is-icons`,a),role:`radiogroup`,"aria-label":r,children:[c?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-seg-ind`,"aria-hidden":`true`,style:{left:c.left,width:c.width,transition:hi(`left`,`width`,u)}}):null,e.map((t,n)=>{let r=/* @__PURE__ */ (0,A.jsxs)(`button`,{ref:e=>{o.current[n]=e},type:`button`,role:`radio`,"aria-checked":n===s,"aria-label":i?t.label:void 0,tabIndex:n===s?0:-1,className:M(`ui-seg-item`,n===s&&`is-selected`),onClick:()=>f(n),onKeyDown:t=>{if(W(t))return;let r=e.length,i=t.key===`ArrowRight`||t.key===`ArrowDown`?(n+1)%r:t.key===`ArrowLeft`||t.key===`ArrowUp`?(n-1+r)%r:-1;i<0||(t.preventDefault(),o.current[i]?.focus(),f(i))},children:[t.icon?/* @__PURE__ */ (0,A.jsx)(fi,{icon:t.icon,size:16,filled:i&&n===s}):null,i?null:/* @__PURE__ */ (0,A.jsx)(`span`,{children:t.label})]},t.id);return i?/* @__PURE__ */ (0,A.jsx)(Zf,{label:t.label,describe:!1,side:`bottom`,children:r},t.id):r})]})}qt(),Hr(),ti(Kt,Vr);function pw({children:e,variant:t=`plain`,className:n}){return/* @__PURE__ */ (0,A.jsxs)(`span`,{className:M(`ui-tag`,t!==`plain`&&`is-`+t,n),children:[t===`forecast`?/* @__PURE__ */ (0,A.jsx)(Y,{name:`trend-up`,size:16}):t===`demo`?/* @__PURE__ */ (0,A.jsx)(Y,{name:`info`,size:16}):null,e]})}function mw({label:e,hint:t,error:n,value:r,onChange:i,maxLength:a=200,className:o,id:s,required:c,...l}){let u=y.useId(),d=s||u,f=n?d+`-err`:t?d+`-hint`:void 0,p=y.useRef(null);return y.useLayoutEffect(()=>{let e=p.current;e&&(e.style.height=`auto`,e.style.height=Math.min(e.scrollHeight+2,230)+`px`)},[r]),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-field`,n&&`has-error`,o),children:[e?/* @__PURE__ */ (0,A.jsx)(T_,{htmlFor:d,required:c,children:e}):null,/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-field-box`,children:[/* @__PURE__ */ (0,A.jsx)(`textarea`,{rows:3,...l,ref:p,id:d,className:`ui-input ui-textarea`,maxLength:a,value:r||``,"aria-required":c||void 0,"aria-describedby":[l[`aria-describedby`],f].filter(Boolean).join(` `)||void 0,"aria-invalid":n?!0:void 0,onChange:e=>i(e.target.value)}),n?/* @__PURE__ */ (0,A.jsx)(D_,{}):null]}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-field-foot`,children:[n?/* @__PURE__ */ (0,A.jsx)(`span`,{id:f,className:`ui-field-error`,role:`alert`,children:n},n):/* @__PURE__ */ (0,A.jsx)(`span`,{id:f,className:`ui-field-hint`,children:t||``}),/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-count`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-seen`,"data-text":a_.fraction((r||``).length,a)})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:a_.fractionLabel((r||``).length,a,w(`字`))})]})]})]})}let hw=[{id:`auto`,label:`自動`},{id:`light`,label:`淺色`},{id:`dark`,label:`深色`}];function gw({value:e,onChange:t,label:n,className:r}){let[i,a]=y.useState(()=>e??um()),o=e??i,s=y.useRef([]),c=e=>{a(e),t?t(e):pm(e)},l=Math.max(0,hw.findIndex(e=>e.id===o));return/* @__PURE__ */ (0,A.jsx)(`div`,{role:`radiogroup`,"aria-label":n||w(`主題`),className:M(`ui-themepick`,r),children:hw.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`button`,{ref:e=>{s.current[t]=e},type:`button`,role:`radio`,"aria-checked":o===e.id,tabIndex:t===l?0:-1,className:M(`ui-themepick-opt`,o===e.id&&`is-on`),onClick:()=>c(e.id),onKeyDown:e=>{if(W(e))return;let n=hw.length,r=e.key===`ArrowRight`||e.key===`ArrowDown`?(t+1)%n:e.key===`ArrowLeft`||e.key===`ArrowUp`?(t-1+n)%n:-1;r<0||(e.preventDefault(),s.current[r]?.focus(),c(hw[r].id))},children:[/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-themepick-mini is-`+e.id,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{}),/* @__PURE__ */ (0,A.jsx)(`span`,{})]}),w(e.label)]},e.id))})}let _w=`ui-tour:`;function vw(e){let[t,n]=y.useState(()=>!!I(_w+e)),[r,i]=y.useState(!1),a=y.useRef(!1);y.useLayoutEffect(()=>{!I(_w+e)&&!a.current&&i(!0)},[e]);let o=()=>{I(_w+e,`1`),n(!0)};return{open:r,start:()=>i(!0),close:()=>{o(),i(!1)},seen:t,hint:(e,n)=>{if(a.current=!0,!(t||r))return{text:e,action:n,onAction:()=>i(!0),onDismiss:o}}}}function yw(e){if(!e)return null;if(typeof e==`string`){let t=/^[\w-]+$/.test(e)&&!/^(html|body|main|nav|header|footer|section|aside)$/.test(e)?`[data-tour="${e}"]`:e;return Array.from(document.querySelectorAll(t)).find(e=>e.getClientRects().length>0)??null}return e instanceof Element?e:e.current}function bw(){return parseFloat(getComputedStyle(document.documentElement).getPropertyValue(`--space-3`))||12}let xw=()=>typeof window<`u`&&window.innerWidth<600;function Sw(e){let t=typeof window>`u`?0:window.innerHeight;if(!xw())return{top:0,bottom:t};let n=0,r=t,i=document.querySelector(`.ui-shell-top`),a=document.querySelector(`.ui-tabbar`);if(i&&!(e&&i.contains(e))){let e=i.getBoundingClientRect();e.height&&e.bottom>0&&e.bottom<t/2&&(n=e.bottom)}if(a&&!(e&&a.contains(e))){let e=a.getBoundingClientRect();e.height&&e.top>t/2&&e.top<t&&(r=e.top)}return{top:n,bottom:r}}let Cw=(e,t)=>Math.max(0,Math.min(e.left+e.width,t.left+t.width)-Math.max(e.left,t.left))*Math.max(0,Math.min(e.top+e.height,t.top+t.height)-Math.max(e.top,t.top));function ww(e,t,n,r,i=320,a=[]){let o=typeof document>`u`?12:bw(),s=typeof window>`u`?0:window.innerWidth,c=r?.bottom??(typeof window>`u`?0:window.innerHeight),l=r?.top??0;if(!e)return{mode:`center`,box:{left:(s-i)/2,top:Math.max(l+o,(l+c)/2-t/2),width:i,height:t},fits:!0};let u=e=>Math.max(o,Math.min(s-o-i,e)),d=e=>Math.max(l+o,Math.min(c-o-t,e)),f=e.left+e.width/2-i/2,p=e.top+e.height/2-t/2,m={bottom:{left:f,top:e.top+e.height+12},top:{left:f,top:e.top-12-t},right:{left:e.left+e.width+12,top:p},left:{left:e.left-12-i,top:p}},h=(n===`top`?[`top`,`bottom`,`right`,`left`]:[`bottom`,`top`,`right`,`left`]).map(n=>{let r=m[n],o={left:u(r.left),top:d(r.top),width:i,height:t},s=n===`bottom`||n===`top`?o.top===r.top:o.left===r.left,c=Cw(o,e),l=a.reduce((e,t)=>e+Cw(o,t),0);return{mode:n,box:o,fits:s&&!c&&!l,onTarget:c,onKept:l}}),g=h.find(e=>e.fits)??[...h].sort((e,t)=>e.onTarget-t.onTarget||e.onKept-t.onKept)[0];return{mode:g.mode,box:g.box,fits:g.fits}}function Tw({open:e,steps:t,onClose:n,skippable:r=!0,step:i,onStepChange:a}){let[o,s]=y.useState(0),c=Math.max(0,Math.min(t.length-1,i??o)),l=t[c],[u,d]=y.useState(null),[f,p]=y.useState([]),m=y.useRef(null),[h,g]=y.useState(0),[_,v]=y.useState(320),[b,x]=y.useState(e);e!==b&&(x(e),e&&i==null&&s(0));let S=e=>{a?.(e),i??s(e)},C=e=>n?.(e);Im(e);let T=y.useRef(-1);y.useEffect(()=>{!e||!l?T.current=-1:(T.current!==-1&&T.current!==c&&bi(w(`第 {a} 步,共 {b} 步`,{a:c+1,b:t.length})+w(`。`)+l.title+w(`。`)+l.text.replace(/`/g,``)),T.current=c)},[e,c,l,t.length]);let E=y.useRef(null),D=()=>Array.from(E.current?.querySelectorAll(`button:not(:disabled), a[href], input:not(:disabled), [tabindex]:not([tabindex="-1"])`)??[]).filter(e=>e.getClientRects().length>0),O=e=>{if(e.key!==`Tab`||e.altKey||e.ctrlKey||e.metaKey)return;let t=D();if(!t.length)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[n<0?0:(n+(e.shiftKey?-1:1)+t.length)%t.length].focus()};y.useEffect(()=>{if(!e)return;let t=e=>{let t=E.current;t&&e.target instanceof Node&&!t.contains(e.target)&&(m.current??D()[0])?.focus()};return document.addEventListener(`focusin`,t),()=>document.removeEventListener(`focusin`,t)},[e]);let k=l?.target,j=l?.padding??6,P=l?.keepVisible==null?[]:Array.isArray(l.keepVisible)?l.keepVisible:[l.keepVisible],F=P.map(e=>typeof e==`string`?e:`#`).join(`|`),I=y.useRef(P);y.useLayoutEffect(()=>{I.current=P});let L=!!l;y.useEffect(()=>{if(!e||!L)return;let t=yw(k),n=(t?.getBoundingClientRect().height??0)>window.innerHeight;if(G(t&&t.getBoundingClientRect().height>window.innerHeight*.7,`Tour`,`第 ${c+1} 步的目標「${k}」比視窗的 70% 高,說明卡只能蓋住它的一部分。請把 data-tour 放在較小的元素上,例如要說明的那張卡片或那一列,而不是整頁。`),t instanceof HTMLElement&&xw()){let e=t.style.scrollMarginTop;t.style.scrollMarginTop=Sw(t).top+bw()+j+`px`,t.scrollIntoView?.({block:`start`,behavior:`auto`}),t.style.scrollMarginTop=e}else t?.scrollIntoView?.({block:n?`start`:`center`,behavior:`auto`});let r=0,i=``,a=()=>{t?.isConnected||(t=yw(k));let e=t?.getBoundingClientRect(),n=null;if(e&&e.width){let t=Math.max(3,e.left-j),r=Math.max(3,e.top-j);n={left:t,top:r,width:Math.max(0,Math.min(window.innerWidth-3,e.right+j)-t),height:Math.max(0,Math.min(window.innerHeight-3,e.bottom+j)-r)}}let o=[];for(let e of I.current){let t=yw(e)?.getBoundingClientRect();t&&t.width&&o.push({left:t.left,top:t.top,width:t.width,height:t.height})}let s=JSON.stringify([n,o]);s!==i&&(i=s,d(n),p(o)),r=requestAnimationFrame(a)};return a(),()=>cancelAnimationFrame(r)},[e,L,c,k,j,F]);let R=y.useRef(null),z=y.useCallback(e=>{if(E.current=e,R.current?.disconnect(),R.current=null,!e)return;let t=()=>{g(e.offsetHeight),v(e.offsetWidth)};t(),R.current=U(t),R.current?.observe(e)},[]),B=h>0;y.useEffect(()=>{if(!e||!L||!B)return;let t=yw(k);if(!(t instanceof HTMLElement))return;let n=Sw(t),r=bw(),i=t.getBoundingClientRect(),a=i.top-j,o=i.bottom+j;if(ww({left:i.left-j,top:a,width:i.width+2*j,height:o-a},h,l?.side??`bottom`,n,_,f).fits)return;let s=o-a+12+h+2*r<=n.bottom-n.top?n.top+r+j:n.top+r+h+12+j,c=t.parentElement;for(;c&&!(/(auto|scroll)/.test(getComputedStyle(c).overflowY)&&c.scrollHeight>c.clientHeight);)c=c.parentElement;let u=i.top-s;c?c.scrollBy({top:u,behavior:`auto`}):window.scrollBy({top:u,behavior:`auto`})},[e,L,c,k,j,B,h]);let V=e&&l?Sw(yw(l.target)):void 0,H=ww(u,h,l?.side??`bottom`,V,_,f),ee=H.box.left,te=H.box.top,ne=y.useMemo(()=>({getBoundingClientRect:()=>new DOMRect(ee,te,0,0)}),[ee,te]);if(!e||!l)return null;let W=c===t.length-1;return/* @__PURE__ */ (0,A.jsx)(rv,{open:!0,modal:!0,onOpenChange:(e,t)=>{t.reason===`escape-key`&&r&&C(`skip`)},children:/* @__PURE__ */ (0,A.jsxs)(lv,{children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tour-layer`,children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-tour-block`,!u&&`is-dim`)}),u?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-tour-spot`,"aria-hidden":`true`,style:u}):null]}),/* @__PURE__ */ (0,A.jsx)(fv,{className:`ui-float ui-tour-float`,anchor:ne,side:`bottom`,align:`start`,sideOffset:0,collisionAvoidance:{side:`none`,align:`none`,fallbackAxisSide:`none`},children:/* @__PURE__ */ (0,A.jsxs)(gv,{ref:z,className:`ui-tour-card`,"data-placement":H.mode,initialFocus:m,onKeyDown:O,children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tour-body`,children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tour-count`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{"aria-hidden":`true`,children:N(w(`{n} / {total}`,{n:``,total:``}),[String(c+1),String(t.length)])}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:w(`第 {a} 步,共 {b} 步`,{a:c+1,b:t.length})})]}),/* @__PURE__ */ (0,A.jsx)(vv,{className:`ui-tour-title`,children:l.title}),/* @__PURE__ */ (0,A.jsx)(Y_,{as:`div`,className:`ui-tour-text`,text:l.text})]}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tour-actions`,children:[r&&!W?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn is-muted`,onClick:()=>C(`skip`),children:w(`略過`)}):null,/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tour-gap`}),c>0?/* @__PURE__ */ (0,A.jsx)(Xp,{onClick:()=>S(c-1),children:w(`上一步`)}):null,/* @__PURE__ */ (0,A.jsx)(Xp,{ref:m,variant:`primary`,onClick:()=>W?C(`done`):S(c+1),children:w(W?`完成`:`下一步`)})]})]},c)})]})})}let Ew={pdf:`pdf`,mp4:`video`,mov:`video`,mkv:`video`,webm:`video`,avi:`video`,mp3:`audio`,wav:`audio`,m4a:`audio`,ppt:`slides`,pptx:`slides`,key:`slides`,odp:`slides`,doc:`doc`,docx:`doc`,txt:`doc`,md:`doc`,odt:`doc`,xls:`sheet`,xlsx:`sheet`,csv:`sheet`,ods:`sheet`,zip:`archive`,rar:`archive`,tar:`archive`,gz:`archive`,"7z":`archive`,png:`image`,jpg:`image`,jpeg:`image`,gif:`image`,svg:`image`,webp:`image`,py:`code`,js:`code`,ts:`code`,c:`code`,cpp:`code`,java:`code`,ipynb:`code`,sh:`code`};function Dw(e){let t=/\.([a-z0-9]+)$/i.exec(e.name||``);return String(e.ext||(t?t[1]:``)).toLowerCase()}let Ow=(e,t)=>e.flatMap(e=>{let n=t(e);return n?[e,...Ow(n,t)]:e.hasChildren?[e]:[]}),kw=e=>e==null?null:e instanceof Date?e:new Date(e);function Aw(e){let t=kw(e.date);for(let n of e.children??[]){let e=Aw(n);e&&(!t||e>t)&&(t=e)}return t}function jw(e,t,n=!1){return n?[...e]:e.map((e,t)=>[e,t]).sort(([e,n],[r,i])=>{let a=!!e.children;if(a!==!!r.children)return a?-1:1;if(!t)return n-i;if(t===`name`)return String(e.name).localeCompare(String(r.name),S.locale,{numeric:!0})||n-i;let o=+(Aw(e)||0),s=+(Aw(r)||0);return(t===`oldest`?o-s:s-o)||n-i}).map(([e])=>e)}function Mw(e,t,n){for(let r of t){if(r.id===e)return r;let t=n(r),i=t&&Mw(e,t,n);if(i)return i}return null}function Nw(e,t,n,r=[]){for(let i of t){let t=[...r,i];if(i.id===e)return t;let a=n(i),o=a&&Nw(e,a,n,t);if(o)return o}return null}Fe(),pt(),Dt(),kt(),ti(Pe,ft,Et,Ot);let Pw=e=>e;function Fw({guides:e}){return/* @__PURE__ */ (0,A.jsx)(A.Fragment,{children:e.map(e=>/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-tree-guide`,e>=3&&`is-deep`),"aria-hidden":`true`,style:Pw({"--g":e})},e))})}function Iw(e){let{items:t}=e,n=e.expand===`single`,r=e.kind===`plain`,i=r&&e.density===`compact`;G(e.density===`compact`&&!r,`TreeList`,`density="compact" works with kind="plain" only: the files kind needs room for date and size.`);let a=e.sort===void 0?!r&&`newest`:e.sort,o=!!e.selectable&&!r;G(r&&e.selectable,`TreeList`,`selectable works with kind="files" only; for plain trees use selectedId and onSelect.`);let[s,c]=y.useState(()=>Object.fromEntries((e.defaultOpen??[]).map(e=>[e,!0]))),l=e.open?Object.fromEntries(e.open.map(e=>[e,!0])):s,[u,d]=y.useState({}),f=e=>{let t=u[e.id];return e.children??(t?.status===`done`?t.children:null)},p=e=>{let t=f(e);return t?t.length>0:!!e.hasChildren},m=t=>{let n=e.loadChildren;n&&!f(t)&&u[t.id]?.status!==`loading`&&(d(e=>({...e,[t.id]:{status:`loading`}})),Promise.resolve().then(()=>n(t)).then(e=>d(n=>({...n,[t.id]:{status:`done`,children:e||[]}})),e=>d(n=>({...n,[t.id]:{status:`error`,error:e instanceof Error?e.message:String(e??``)}}))))},h=e.open?.join(`\0`);y.useEffect(()=>{for(let e of Object.keys(l)){let n=l[e]?Mw(e,t,f):null;n&&m(n)}},[h]);let[g,_]=y.useState({});y.useEffect(()=>{if(!Object.keys(g).length)return;let e=setTimeout(()=>_({}),400);return()=>clearTimeout(e)},[g]);let[v,b]=y.useState([]),x=e.selected??v,S=t=>{e.selected||b(t),e.onSelectChange?.(t)},C=y.useId().replace(/:/g,``),[T,E]=y.useState(null),D=y.useRef({}),O=y.useRef(null);y.useEffect(()=>{O.current&&=(D.current[O.current]?.focus(),null)});let k=new Set(x),N=e=>{let t=f(e);return t?t.flatMap(N):e.hasChildren?[]:[e]},P=t.flatMap(N),F=r=>{let i={...l},a=!i[r.id];if(n&&a){let e=Nw(r.id,t,f),n=(e&&e.length>1?f(e[e.length-2]):t)??[];for(let e of n)e.id!==r.id&&(i[e.id]=!1)}i[r.id]=a,_(a&&!L()?{[r.id]:!0}:{}),a&&m(r),e.onToggle?.(r,a,Object.keys(i).filter(e=>i[e])),e.open||c(i);let o=a?f(r):null;bi(a?o?w(`已展開,{n} 個子項目`,{n:o.length}):w(`已展開`):w(`已收合`))},I=e=>{let t=N(e),n=t.filter(e=>k.has(e.id)).length;return n===0?!1:n===t.length||`mixed`},R=e=>{let t=I(e)!==!0,n=new Set(k);for(let r of N(e))t?n.add(r.id):n.delete(r.id);S(P.filter(e=>n.has(e.id)).map(e=>e.id))},z=t=>e.onOpen?e.onOpen(t):e.onDownload?.([t]),B=[],V=(t,n,i,o)=>{let s=jw(t,a,r&&!a);s.forEach((t,a)=>{let c=r?p(t):!!(t.children||t.hasChildren),d=c&&!!l[t.id];if(B.push({n:t,depth:n,guides:i,fresh:o,isF:c,open:d,pos:a+1,size:s.length}),!d)return;let m=f(t),h=u[t.id],_=[...i,n];m?V(m,n+1,_,o||!!g[t.id]):h?.status===`error`?B.push({x:`error`,n:t,depth:n+1,guides:_,error:h.error}):e.loadChildren&&B.push({x:`loading`,n:t,depth:n+1,guides:_})})};V(t,0,[],!1);let H=B.filter(e=>!e.x),U=Math.max(0,H.findIndex(e=>e.n.id===T)),ee=e=>{H[e]&&(O.current=H[e].n.id,E(H[e].n.id))},te=y.useRef(null);y.useLayoutEffect(()=>{for(let e of te.current?.querySelectorAll(`[role="treeitem"] :is(a[href], button, input, select, textarea, [tabindex])`)??[])e.tabIndex>=0&&e.getAttribute(`role`)!==`treeitem`&&(e.tabIndex=-1)});let ie=e=>[...e.querySelectorAll(`a[href], button, input, select, textarea, [tabindex]`)].filter(t=>t.closest(`[role="treeitem"]`)===e&&t.getAttribute(`role`)!==`treeitem`&&!t.closest(`[aria-hidden="true"]`)&&!t.matches(`:disabled`)),K=t=>{if(!H.length||W(t))return;let n=t.target,i=n.closest(`[role="treeitem"]`);if(i&&i!==n){let e=ie(i),r=e.indexOf(n);if(t.key===`ArrowRight`&&r<e.length-1)e[r+1].focus();else if(t.key===`ArrowLeft`&&r>0)e[r-1].focus();else if(t.key===`ArrowLeft`||t.key===`Escape`)i.focus();else if(t.key===`ArrowDown`||t.key===`ArrowUp`)ee(U+(t.key===`ArrowDown`?1:-1));else return;t.preventDefault();return}if(n.getAttribute(`role`)!==`treeitem`)return;let a=H[U],s=t.key;if([`ArrowDown`,`ArrowUp`,`Home`,`End`,`ArrowRight`,`ArrowLeft`,`Enter`].includes(s)||s===` `&&o){if(t.preventDefault(),s===`ArrowDown`)ee(U+1);else if(s===`ArrowUp`)ee(U-1);else if(s===`Home`)ee(0);else if(s===`End`)ee(H.length-1);else if(s===`ArrowRight`){let e=ie(n);a.isF&&!a.open?F(a.n):e.length?e[0].focus():a.isF&&ee(U+1)}else if(s===`ArrowLeft`){if(a.isF&&a.open)F(a.n);else for(let e=U-1;e>=0;e--)if(H[e].depth<a.depth){ee(e);break}}else if(s===`Enter`){if(r){let t=e.selectedId!=null&&e.selectedId===a.n.id;e.onSelect?.(a.n),a.isF&&!t&&F(a.n)}else a.isF?F(a.n):z(a.n)}else R(a.n)}},q=(e,t)=>({ref:t=>{D.current[e.n.id]=t},role:`treeitem`,tabIndex:t===U?0:-1,"aria-level":e.depth+1,"aria-posinset":e.pos,"aria-setsize":e.size,"aria-expanded":e.isF?e.open:void 0,"aria-owns":e.isF&&e.open?`${C}-g-${j(e.n.id)}`:void 0,style:Pw({"--d":e.depth}),onFocus:()=>T!==e.n.id&&E(e.n.id)}),ae=(t,n)=>{let{n:r,isF:a}=t,o=e.selectedId!=null&&e.selectedId===r.id,s=r.meta??(r.path?a_.path(r.path):``);return/* @__PURE__ */ (0,A.jsxs)(`div`,{...q(t,n),"aria-label":r.ariaLabel??[r.name,...(r.tags??[]).map(re),r.meta,r.path,r.mark?.label].filter(Boolean).join(w(`,`)),"aria-selected":e.onSelect?o:void 0,className:M(`ui-tree-row`,`is-plain`,o&&`is-current`,r.muted&&`is-muted`,t.fresh&&`ui-tree-in`),onClick:()=>{T!==r.id&&E(r.id),e.onSelect?.(r),a&&!o&&F(r)},children:[/* @__PURE__ */ (0,A.jsx)(Fw,{guides:t.guides}),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,tabIndex:-1,className:M(`ui-tree-caret`,`ui-tree-caretbtn`,t.open&&`is-open`,!a&&`is-leaf`),"aria-hidden":`true`,onClick:e=>{e.stopPropagation(),a&&F(r)},children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-right`,size:i?14:16})}),r.icon?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-picon`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(fi,{icon:r.icon,size:i?16:20})}):null,/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tree-main`,children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tree-name`,children:[t.depth>3?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-depth`,"aria-hidden":`true`,title:w(`第 {n} 層`,{n:t.depth+1}),children:`L`+(t.depth+1)}):null,/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-label is-one`,children:r.name}),(r.tags??[]).map((e,t)=>/* @__PURE__ */ (0,A.jsx)(pw,{children:e},t))]}),s?/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-tree-pmeta`,r.meta==null&&`is-path`),children:r.meta==null?s:ne(s,/(\d[\d,.]*)/)}):null]}),r.mark?/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-tree-mark`,`is-`+(r.mark.tone??`warning`)),"aria-hidden":`true`,title:r.mark.label}):null,e.rowActions?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-act`,onClick:e=>e.stopPropagation(),children:e.rowActions(r)}):null]},r.id)},oe=e=>/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-tree-row is-plain is-extra`,e.x===`error`&&`is-error`),style:Pw({"--d":e.depth}),role:`none`,children:[/* @__PURE__ */ (0,A.jsx)(Fw,{guides:e.guides}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-caret is-leaf`,"aria-hidden":`true`}),e.x===`loading`?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-tree-main`,children:/* @__PURE__ */ (0,A.jsx)(uw,{width:`55%`,height:14})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,role:`status`,children:w(`載入中`)})]}):/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tree-main`,role:`alert`,children:[w(`無法載入 {name} 的子項目`,{name:e.n.name}),e.error?w(`:`)+e.error:``,w(`。`).trim()]}),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn`,onClick:()=>{d(({[e.n.id]:t,...n})=>n),setTimeout(()=>m(e.n),0)},children:w(`重試`)})]})]},`${e.n.id}:${e.x}`),se=(t,n)=>{let{n:r,isF:i}=t,a=o?I(r):!1,s=i?``:Dw(r),c=Ew[s]||`other`,l=i?N(r):[],u=i?Aw(r):kw(r.date),d=u?a_.relative(u):``,f=i?``:e_(r.size),p=l.filter(e=>e.unseen).length,m=!i&&!!r.unseen,h=(i?[l.length?w(`{n} 個檔案`,{n:l.length}):``,d]:[d,f]).filter(Boolean);return/* @__PURE__ */ (0,A.jsxs)(`div`,{...q(t,n),"aria-label":r.ariaLabel,"aria-selected":o?a===!0:void 0,className:M(`ui-tree-row`,i&&`is-folder`,a===!0&&`is-selected`,t.fresh&&`ui-tree-in`),onClick:()=>{E(r.id),i?F(r):z(r)},children:[/* @__PURE__ */ (0,A.jsx)(Fw,{guides:t.guides}),o?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-sel`,children:/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,role:`checkbox`,tabIndex:-1,"aria-checked":a,"aria-label":w(`選取 {name}`,{name:r.name}),className:M(`ui-check`,a&&`is-on`),onClick:e=>{e.stopPropagation(),R(r)},children:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-check-box`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(E_,{v:a})})})}):null,i?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-tree-caret`,t.open&&`is-open`),"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-right`,size:16})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-ficon`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(Y,{name:t.open?`folder-open`:`folder`,size:24})})]}):/* @__PURE__ */ (0,A.jsxs)(`span`,{className:M(`ui-tree-doc`,`is-`+c),"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsxs)(`svg`,{width:30,height:36,viewBox:`0 0 30 36`,children:[/* @__PURE__ */ (0,A.jsx)(`path`,{d:`M5 1.5h15l7.5 7.5v25.5H5z`}),/* @__PURE__ */ (0,A.jsx)(`path`,{d:`M20 1.5V9h7.5`,fill:`none`})]}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-ext`,children:(s||`?`).slice(0,4).toUpperCase()})]}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tree-main`,children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tree-name`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-label`,children:r.name}),p?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-newcount`,children:w(`{n} 個新`,{n:p})}):null,i&&l.length?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-count ui-tree-mc`,children:w(`{n} 個檔案`,{n:l.length})}):null]}),h.length?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-tree-meta ui-tree-mb`,children:h.map((e,t)=>/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(!i&&e===d&&m&&`is-new`),children:(t?`· `:``)+e},t))}):null]}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-tree-col`,`ui-tree-date`,`ui-tree-mc`,m&&`is-new`),children:d}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-col ui-tree-size ui-tree-mc`,children:f}),e.onDownload?i?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-actsp`,"aria-hidden":`true`}):/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-act`,children:/* @__PURE__ */ (0,A.jsx)(np,{label:w(`下載 {name}`,{name:r.name}),icon:`download-simple`,tabIndex:-1,onClick:t=>{t.stopPropagation(),e.onDownload?.([r])}})}):null]},r.id)},ce=Ow(t,f),le=ce.some(e=>!l[e.id]),J=P.filter(e=>k.has(e.id)),ue=J.reduce((e,t)=>e+(t.size||0),0),de=!n&&ce.length>0&&(!r||!!e.toggleAll)&&(!e.open||!!e.onToggleAll);G(e.open&&(!r||e.toggleAll)&&!n&&!e.onToggleAll,`TreeList`,`with controlled open ids, 「全部展開」 needs onToggleAll to report the new ids; it is hidden until you pass it.`);let fe=o&&J.length?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tree-head ui-tree-bulk`,children:[/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-tree-bulk-count`,children:[w(`已選 {n} 個檔案`,{n:J.length}),ue?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-bulk-size`,children:w(`共 {size}`,{size:e_(ue)})}):null]}),/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-tree-head-actions`,children:[/* @__PURE__ */ (0,A.jsx)(Xp,{onClick:()=>S([]),children:w(`清除選取`)}),e.onDownload?/* @__PURE__ */ (0,A.jsx)(Xp,{variant:`primary`,icon:`download-simple`,onClick:()=>{e.onDownload?.(J),S([])},children:w(`下載`)}):null,e.bulkActions?.(J,()=>S([]))]})]}):e.title||e.actions||de?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tree-head`,children:[e.title?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tree-titles`,children:[/* @__PURE__ */ (0,A.jsx)(`h2`,{className:`ui-tree-title`,children:e.title}),e.subtitle?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-tree-subtitle`,children:e.subtitle}):null]}):/* @__PURE__ */ (0,A.jsx)(`span`,{}),/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-tree-head-actions`,children:[de?/* @__PURE__ */ (0,A.jsx)(Xp,{onClick:()=>{let t=Object.fromEntries(ce.map(e=>[e.id,le]));_(le&&!L()?Object.fromEntries(ce.filter(e=>!l[e.id]).map(e=>[e.id,!0])):{}),e.open?e.onToggleAll?.(le,le?[.../* @__PURE__ */ new Set([...e.open,...ce.map(e=>e.id)])]:[]):c(t)},children:w(le?`全部展開`:`全部收合`)}):null,e.actions??null]})]}):null,pe=e=>e.x?oe(e):r?ae(e,H.indexOf(e)):se(e,H.indexOf(e)),me=(e,t)=>{let n=[],r=e;for(;r<B.length&&B[r].depth>=t;){let e=B[r];if(n.push(pe(e)),r++,!e.x&&e.open&&r<B.length&&B[r].depth>t){let[i,a]=me(r,t+1);n.push(/* @__PURE__ */ (0,A.jsx)(`div`,{id:`${C}-g-${j(e.n.id)}`,role:`group`,className:`ui-tree-group`,children:i},`g-`+e.n.id)),r=a}}return[n,r]};return/* @__PURE__ */ (0,A.jsxs)(`section`,{className:M(`ui-tree`,r&&`is-plain`,i&&`is-compact`,o&&`is-selectable`,J.length&&`has-sel`,e.bare&&`is-bare`,e.height!=null&&`has-height`,e.className),"aria-label":e.title?void 0:e.label,style:e.height==null?void 0:{height:typeof e.height==`number`?e.height+`px`:e.height},children:[fe,H.length?/* @__PURE__ */ (0,A.jsx)(`div`,{role:`tree`,"aria-label":e.label||(typeof e.title==`string`?e.title:void 0),"aria-multiselectable":o||void 0,className:`ui-tree-list`,ref:te,onKeyDown:K,children:me(0,0)[0]}):/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-tree-empty`,children:e.emptyText||w(r?`沒有項目`:`這裡還沒有檔案`)})]})}ai(Gr);let Lw={close:`x`,edit:`pencil-simple`,more:`dots-three`,spinner:`circle-notch`,alert:`warning-circle`,warn:`warning`,chevronRight:`caret-right`,chevronDown:`caret-down`,panelClose:`sidebar-simple`,panelOpen:`sidebar-simple`,filter:`funnel`,refresh:`arrows-clockwise`},Rw=Object.fromEntries(Gr.map(e=>[e.n,e.r])),zw=Object.freeze({...Object.fromEntries(Object.entries(Lw).map(([e,t])=>[e,Rw[t]])),...Rw,...Object.fromEntries(Object.entries(Kr).map(([e,t])=>[e,Rw[t]]))});je(),Ne(),Fe(),ti(Ae,Me,Pe);let Bw=y.createContext(null);function Vw(){let e=y.useContext(Bw);if(!e)throw Error(`useWorkbench() works inside <Workbench>.`);return e}let Hw={explorer:[180,480],side:[240,560],panel:[120,1/0]},Uw={explorer:260,side:320,panel:220},Ww={explorer:[`<rect x="40" y="56" width="64" height="144" rx="6"/>`,`<path d="M100 44v168" stroke="currentColor" stroke-width="16"/>`],side:[`<rect x="152" y="56" width="64" height="144" rx="6"/>`,`<path d="M156 44v168" stroke="currentColor" stroke-width="16"/>`],panel:[`<rect x="40" y="136" width="176" height="64" rx="6"/>`,`<path d="M28 140h200" stroke="currentColor" stroke-width="16"/>`]},Gw=(e,t)=>`<rect x="24" y="40" width="208" height="176" rx="20" fill="none" stroke="currentColor" stroke-width="16"/>`+Ww[e][+!t];function Kw(e,t){let n=e.map(e=>e.id),r=(t?.side??[]).filter(e=>n.includes(e)),i=(t?.panel??[]).filter(e=>n.includes(e)&&!r.includes(e));for(let e of n)!r.includes(e)&&!i.includes(e)&&i.push(e);return{side:r,panel:i,active:{side:r[0],panel:i[0]},open:{explorer:!0,side:!0,panel:!0,...t?.open},size:{...Uw,...t?.size}}}function qw(e,t){try{let n=I(e);if(!n)return t;let r=JSON.parse(n),i=[...t.side,...t.panel],a=(r.side??[]).filter(e=>i.includes(e)),o=(r.panel??[]).filter(e=>i.includes(e)&&!a.includes(e));for(let e of t.side)!a.includes(e)&&!o.includes(e)&&a.push(e);for(let e of t.panel)!a.includes(e)&&!o.includes(e)&&o.push(e);return{side:a,panel:o,active:{...t.active,...r.active},open:{...t.open,...r.open},size:{...t.size,...r.size}}}catch{return t}}let Jw=(e,t,n)=>Math.max(t,Math.min(n,Math.round(e))),Yw=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName));function Xw(e){let t=y.useRef(null),[n,r]=y.useState(!1),i=t=>e.vertical?t.clientX:t.clientY;return/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-wb-split`,e.vertical?`is-v`:`is-h`,n&&`is-on`),role:`separator`,"aria-orientation":e.vertical?`vertical`:`horizontal`,"aria-label":e.label,"aria-valuenow":e.value,"aria-valuemin":e.min,"aria-valuemax":e.max,tabIndex:0,style:e.style,onPointerDown:n=>{n.currentTarget.setPointerCapture?.(n.pointerId),t.current={at:i(n),v:e.value},r(!0),e.onDrag(!0)},onPointerMove:n=>{let r=t.current;r&&e.onChange(Jw(r.v+(i(n)-r.at)*e.grow,e.min,e.max))},onPointerUp:()=>{t.current=null,r(!1),e.onDrag(!1)},onPointerCancel:()=>{t.current=null,r(!1),e.onDrag(!1)},onDoubleClick:e.onReset,onKeyDown:t=>{let n=t.shiftKey?64:16,r=e.vertical?e.grow>0?`ArrowRight`:`ArrowLeft`:e.grow>0?`ArrowDown`:`ArrowUp`,i=e.vertical?e.grow>0?`ArrowLeft`:`ArrowRight`:e.grow>0?`ArrowUp`:`ArrowDown`,a=null;t.key===r?a=e.value+n:t.key===i?a=e.value-n:t.key===`Home`?a=e.min:t.key===`End`&&(a=e.max),a!=null&&(t.preventDefault(),e.onChange(Jw(a,e.min,e.max)))},children:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-wb-split-line`,"aria-hidden":`true`})})}function Zw(e){let t=y.useRef(null),n=y.useRef({}),r=y.useRef({}),[i,a]=y.useState(e.ids.length),[o,s]=y.useState(null),[c,l]=y.useState(!0),[u,d]=y.useState({left:!1,right:!1}),[f,p]=y.useState(null),m=y.useRef(null),h=y.useRef(e.active),g=e.overflow===`menu`,_=f?(()=>{let t=e.ids.filter(e=>e!==f.id);return t.splice(f.at,0,f.id),t})():e.ids,v=_,b=[];g&&i<_.length&&(v=_.slice(0,Math.max(1,i)),e.active&&_.includes(e.active)&&!v.includes(e.active)&&(v=[...v.slice(0,-1),e.active]),b=_.filter(e=>!v.includes(e)));let x=y.useCallback(()=>{let i=t.current;if(!i)return;let o=e.active?n.current[e.active]:null;s(o?{left:o.offsetLeft+10,right:i.clientWidth-o.offsetLeft-o.offsetWidth+10}:null);let c=i.scrollLeft>1,l=i.scrollLeft+i.clientWidth<i.scrollWidth-1;if(d(e=>e.left===c&&e.right===l?e:{left:c,right:l}),g){for(let[e,t]of Object.entries(n.current))t&&(r.current[e]=t.offsetWidth);let t=0,o=0,s=e.ids.reduce((e,t)=>e+(r.current[t]??80),0),c=i.clientWidth-(s>i.clientWidth?72:0);for(let n of e.ids){if(t+=r.current[n]??80,t>c)break;o++}a(e=>e===o?e:o)}},[e.active,e.ids,g]);y.useLayoutEffect(()=>{h.current!==e.active&&(l(e.ids.indexOf(e.active??``)>e.ids.indexOf(h.current??``)),h.current=e.active),x();let r=t.current;if(!r)return;let i=e.active?n.current[e.active]:null;i&&!g&&(i.offsetLeft<r.scrollLeft?r.scrollLeft=i.offsetLeft-4:i.offsetLeft+i.offsetWidth>r.scrollLeft+r.clientWidth&&(r.scrollLeft=i.offsetLeft+i.offsetWidth-r.clientWidth+4));let a=U(x);return a?.observe(r),()=>a?.disconnect()},[e.active,e.ids,x,g,f]);let S=e.drag,C=S?.over?.region===e.region?S.over:void 0,T=S?e.ids.indexOf(S.id):-1,E=t=>T>=0&&(t===S?.id||t===(e.ids[T+1]??null)),D=(t,r,i)=>{let a=e.views[t],o=t===e.active,s=i[r+1]??null,c=!!C&&!C.noop&&C.before===t,l=!!C&&!C.noop&&C.before===null&&r===i.length-1&&i.length===e.ids.length;return/* @__PURE__ */ (0,A.jsxs)(`button`,{ref:e=>{n.current[t]=e},type:`button`,role:`tab`,"data-id":t,"aria-selected":o,tabIndex:o?0:-1,className:M(`ui-wb-tab`,o&&`is-on`,S?.id===t&&`is-ghost`,f?.id===t&&`is-held`,c&&`has-line`,l&&`has-line-after`),draggable:!!e.setDrag,onClick:()=>e.onPick(t),onKeyDown:t=>{let a=t.key,o=a===`ArrowRight`?r+1:a===`ArrowLeft`?r-1:a===`Home`?0:a===`End`?i.length-1:-1;o<0||o>=i.length||(t.preventDefault(),e.onPick(i[o]),n.current[i[o]]?.focus())},onDragStart:n=>{n.dataTransfer.setData(`text/plain`,t),n.dataTransfer.effectAllowed=`move`,e.setDrag?.({id:t})},onDragEnd:()=>e.setDrag?.(null),onDragOver:n=>{if(!S||!e.setDrag)return;n.preventDefault(),n.stopPropagation();let r=n.currentTarget.getBoundingClientRect(),i=n.clientX>r.left+r.width/2?s:t,a=E(i);C&&C.before===i&&C.noop===a||e.setDrag({id:S.id,over:{region:e.region,before:i,noop:a}})},onDrop:t=>{t.preventDefault(),t.stopPropagation(),S&&C&&!C.noop&&e.onDrop?.(S.id,C.before),e.setDrag?.(null)},children:[a.title,a.attention?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-wb-dot`,"aria-label":w(`有新內容`),role:`img`}):null]},t)},O=e.onReorder?{onPointerDown:t=>{let n=t.target.closest?.(`[data-id]`),r=t.currentTarget,i={id:n?n.getAttribute(`data-id`):null,x:t.clientX,y:t.clientY,scroll:r.scrollLeft,mode:null,timer:void 0};i.timer=setTimeout(()=>{m.current===i&&!i.mode&&i.id&&(i.mode=`drag`,r.setPointerCapture?.(t.pointerId),navigator.vibrate?.(10),p({id:i.id,at:e.ids.indexOf(i.id)}))},300),m.current=i},onPointerMove:e=>{let t=m.current;if(!t)return;let n=e.clientX-t.x;!t.mode&&(Math.abs(n)>8||Math.abs(e.clientY-t.y)>8)&&(clearTimeout(t.timer),t.mode=`scroll`);let r=e.currentTarget;if(t.mode===`scroll`)r.scrollLeft=t.scroll-n;else if(t.mode===`drag`&&t.id){let n=0;r.querySelectorAll(`[data-id]`).forEach(r=>{if(r.getAttribute(`data-id`)===t.id)return;let i=r.getBoundingClientRect();e.clientX>i.left+i.width/2&&n++}),p(e=>e&&e.at===n?e:{id:t.id,at:n});let i=r.getBoundingClientRect();e.clientX<i.left+28?r.scrollLeft-=6:e.clientX>i.right-28&&(r.scrollLeft+=6)}},onPointerUp:()=>{let t=m.current;if(m.current=null,t&&(clearTimeout(t.timer),t.mode===`drag`&&f)){let t=_;p(null),t.join(`
89
+ `){if(/ {2,}$/.test(i))i=i.replace(/ +$/,``),a(),r.push(/* @__PURE__ */ (0,A.jsx)(`br`,{},t.k()));else{i=i.replace(/ +$/,``);let t=i.at(-1)??(typeof r.at(-1)==`string`?String(r.at(-1)).at(-1):``),n=e.slice(o+1).trimStart()[0]??``;for(!Hb.test(t??``)&&!Hb.test(n)&&(i+=` `);e[o+1]===` `;)o++}o++}else{if(c==="`"){let n=/^`+/.exec(e.slice(o))?.[0]??"`",i=e.indexOf(n,o+n.length);if(i>0){a();let c=e.slice(o+n.length,i).replace(/\n/g,` `);/^ .* $/.test(c)&&(c=c.slice(1,-1)),r.push(s(c,t)),o=i+n.length;continue}}if(c===`<`){let n=/^<((?:https?:|mailto:)[^\s<>]+)>/i.exec(e.slice(o));if(n){a(),r.push(Kb(n[1],[n[1].replace(/^mailto:/i,``)],t)),o+=n[0].length;continue}let i=/^<!--[\s\S]*?-->|^<\/?[A-Za-z][\w-]*(?:\s[^<>]*)?\/?>/.exec(e.slice(o));if(i){o+=i[0].length;continue}}if(c===`!`&&e[o+1]===`[`){let t=/^!\[([^\]]*)\]\([^)]*\)/.exec(e.slice(o));if(t){i+=t[1],o+=t[0].length;continue}}if(c===`[`){let i=Wb(e,o);if(i){if(i.href.trim().toLowerCase()===`ai:`){let t=i.text.trim();n=t&&t!==`AI`?t:``,o=i.end,e[o]===` `&&o++;continue}a();let s=/^term:(.*)$/i.exec(i.href.trim())?.[1];if(s!==void 0){let e=s;try{e=decodeURIComponent(s)}catch{}let n=t.terms?.find(t=>t.term===e);G(!n,`Markdown`,`[${i.text}](term:${s}) 找不到 terms 裡 term 為「${e}」的項目,只顯示文字。把它加進 terms,或改 term: 後面的字。`),t.seen?.add(e),r.push(n?Av(n,t.k(),Ub(i.text,Vb(t))):/* @__PURE__ */ (0,A.jsx)(y.Fragment,{children:Ub(i.text,Vb(t))},t.k())),o=i.end;continue}let c=/^\s*`([^`]+)`\s*$/.exec(i.text)?.[1];r.push(Kb(i.href,Ub(i.text,Vb(t)),t,c)),o=i.end;continue}}if(c===`*`||c===`_`){let n=e[o+1]===c?c+c:c,i=e[o-1],s=c===`_`&&i!==void 0&&/\w/.test(i),l=e[o+n.length];if(!s&&l&&!/\s/.test(l)){let i=Gb(e,o+n.length,n);if(i>0){a();let s=Ub(e.slice(o+n.length,i),t);r.push(n.length===2?/* @__PURE__ */ (0,A.jsx)(`strong`,{children:s},t.k()):/* @__PURE__ */ (0,A.jsx)(`em`,{children:s},t.k())),o=i+n.length;continue}}}i+=c,o++}}if(a(),n!=null){let e=r[r.length-1];typeof e==`string`&&(r[r.length-1]=e.replace(/\s+$/,``)),r.push(/* @__PURE__ */ (0,A.jsx)(bb,{text:n||void 0},t.k()))}return r;function s(e,t){let n=t.onRef;if(Rb(e)){let r=t.refHref?.(e)||void 0,i=n?t=>{r&&(t.metaKey||t.ctrlKey||t.shiftKey||t.button===1)||(t.preventDefault(),n(e,t))}:void 0;if(r)return/* @__PURE__ */ (0,A.jsx)(em,{look:`location`,href:r,onClick:i,children:e},t.k());if(i)return/* @__PURE__ */ (0,A.jsx)(em,{look:`location`,onClick:i,children:e},t.k())}return/* @__PURE__ */ (0,A.jsx)(em,{children:e},t.k())}}function Wb(e,t){let n=0,r=t;for(;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===`[`)n++;else if(e[r]===`]`&&--n===0)break;if(r>=e.length||e[r+1]!==`(`)return null;let i=r+2;for(;e[i]===` `;)i++;let a=0,o=``;for(;i<e.length;i++){let t=e[i];if(/\s/.test(t))break;if(t===`(`)a++;else if(t===`)`){if(a===0)break;a--}o+=t}let s=/^(?:\s+(?:"[^"]*"|'[^']*'))?\s*\)/.exec(e.slice(i));return s?{text:e.slice(t+1,r),href:o.replace(/^<(.*)>$/,`$1`),end:i+s[0].length}:null}function Gb(e,t,n){let r=t;for(;(r=e.indexOf(n,r))>0;){let t=e[r-1],i=e[r+n.length];if(t&&!/\s/.test(t)&&!(n[0]===`_`&&i&&/\w/.test(i))&&(n.length!==1||i!==n))return r;r+=n.length}return-1}function Kb(e,t,n,r){let i=/^([a-z][a-z0-9+.-]*):/i.exec(e.trim())?.[1].toLowerCase(),a=!!i&&!zb.includes(i)&&!!n.schemes?.some(e=>e.toLowerCase()===i),o=a?e.trim():Ib(e);if(o===void 0)return/* @__PURE__ */ (0,A.jsx)(y.Fragment,{children:t},n.k());let s=n.linkHref?n.linkHref(o)||void 0:a?void 0:o;if(!s&&!n.onLink)return/* @__PURE__ */ (0,A.jsx)(y.Fragment,{children:t},n.k());let c=!!s&&/^https?:/i.test(s),l=n.onLink,u=l?e=>{s&&(e.metaKey||e.ctrlKey||e.shiftKey||e.button===1)||(e.preventDefault(),l(o,e))}:void 0;if(r!==void 0&&(!c||n.onLink)){if(s)return/* @__PURE__ */ (0,A.jsx)(em,{look:`name`,href:s,onClick:u,children:r},n.k());if(u)return/* @__PURE__ */ (0,A.jsx)(em,{look:`name`,onClick:u,children:r},n.k())}return s?/* @__PURE__ */ (0,A.jsx)(`a`,{className:`ui-md-link`,href:s,onClick:u,...c&&!n.onLink?{target:`_blank`,rel:`noopener noreferrer`}:{},children:t},n.k()):/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-md-link`,onClick:u,children:t},n.k())}function qb(e){let t=e.filter(e=>!(typeof e==`string`&&!e.trim()));if(t.length!==1)return null;let n=t[0];return!y.isValidElement(n)||n.type!==`a`&&n.type!==`button`||n.props.className!==`ui-md-link`?null:y.cloneElement(n,{className:`ui-md-link is-row`})}let Jb={python:`py`,javascript:`js`,typescript:`js`,jsx:`js`,tsx:`js`,bash:`sh`,shell:`sh`,zsh:`sh`,console:`sh`,"c++":`c`},Yb=e=>Jb[e]??(Pv(`x.`+e)===`plain`?e||`plain`:Pv(`x.`+e)),Xb=/^([-+]?(?:NT\$\s?)?[\d,]+(?:\.\d+)?)(\s?)(%|[A-Za-z]{1,3}|\p{Script=Han}{1,2})$/u,Zb=/^[-+]?(?:NT\$\s?)?[\d,]+(?:\.\d+)?\s?(?:%|[A-Za-z]{1,3}|\p{Script=Han}{1,2})?$/u;function Qb(e){let t=0,n=e.termsMark??`first`,r=y.useMemo(()=>Ov(e.terms),[e.terms]),i={k:()=>`m`+t++,schemes:e.schemes,linkHref:e.linkHref,onLink:e.onLink,refHref:e.refHref,onRef:e.onRef,terms:e.terms,termsMark:n,termRe:r},a=String(e.children??``).replace(/\r\n?/g,`
90
+ `),o=M(`ui-md`,e.size===`small`&&`is-small`,e.className);if(e.inline)return/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(o,`is-inline`),children:Ub(a.trim().replace(/\n\s*\n/g,`
91
+ `),Bb(i))});let s=e.topLevel??4,c=t=>t.map(t=>{switch(t.t){case`h`:{let e=`h${Math.min(6,s+t.level-1)}`;return/* @__PURE__ */ (0,A.jsx)(e,{className:`ui-md-h`,children:Ub(t.text,Vb(i))},i.k())}case`p`:return/* @__PURE__ */ (0,A.jsx)(`p`,{children:Ub(t.text,Bb(i))},i.k());case`hr`:return/* @__PURE__ */ (0,A.jsx)(`hr`,{},i.k());case`details`:return/* @__PURE__ */ (0,A.jsx)(ex,{summary:Ub(t.summary,Vb(i)),children:c(t.blocks)},i.k());case`alert`:return/* @__PURE__ */ (0,A.jsx)(Gg,{tone:t.tone,className:`ui-md-alert`,children:c(t.blocks)},i.k());case`quote`:return/* @__PURE__ */ (0,A.jsx)(`blockquote`,{children:c(t.blocks)},i.k());case`list`:{let e=t.items.map(e=>{let t=i.k();if(e.length!==1||e[0].t!==`p`)return/* @__PURE__ */ (0,A.jsx)(`li`,{children:c(e)},t);let n=Ub(e[0].text,Bb(i)),r=qb(n);return r?/* @__PURE__ */ (0,A.jsx)(`li`,{className:`ui-md-rowitem`,children:r},t):/* @__PURE__ */ (0,A.jsx)(`li`,{children:n},t)});return t.ordered?/* @__PURE__ */ (0,A.jsx)(`ol`,{start:t.start===1?void 0:t.start,children:e},i.k()):/* @__PURE__ */ (0,A.jsx)(`ul`,{children:e},i.k())}case`code`:return/* @__PURE__ */ (0,A.jsx)($v,{className:`ui-md-code`,code:t.code,language:Yb(t.lang),languageLabel:t.lang?void 0:!1,copy:!0,lineNumbers:!1,refHref:e.refHref,onRef:e.onRef,terms:e.terms,termsMark:n},i.k());case`table`:{let e=t.head.length,n=t.head.map((e,n)=>t.rows.length>0&&t.rows.every(e=>!e[n]||Zb.test(e[n])));return/* @__PURE__ */ (0,A.jsx)(tx,{label:t.head.map($b).join(`、`),heads:t.head.map(e=>Ub(e,Vb(i))),headText:t.head.map($b),rows:t.rows.map(t=>Array.from({length:e},(e,r)=>{let a=n[r]?Xb.exec(t[r]??``):null;return a?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[Ub(a[1],Bb(i)),a[2],/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-unit`,children:a[3]})]}):Ub(t[r]??``,Bb(i))})),numeric:n,align:e=>{let r=t.align[e]??(n[e]?`right`:null);return r?{textAlign:r}:void 0}},i.k())}}});return/* @__PURE__ */ (0,A.jsx)(`div`,{className:o,children:c(Fb(a.split(`
92
+ `)))})}let $b=e=>e.replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/[`*_]/g,``).trim();function ex({summary:e,children:t}){let[n,r]=y.useState(!1),i=y.useId(),a=y.useRef(null);return y.useLayoutEffect(()=>{let e=a.current;if(!e)return;if(n){e.removeAttribute(`hidden`);return}e.setAttribute(`hidden`,`until-found`);let t=()=>r(!0);return e.addEventListener(`beforematch`,t),()=>e.removeEventListener(`beforematch`,t)},[n]),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-md-details`,n&&`is-open`),children:[/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:`ui-md-summary`,"aria-expanded":n,"aria-controls":i,onClick:()=>r(!n),children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-right`,size:16,className:`ui-md-caret`}),/* @__PURE__ */ (0,A.jsx)(`span`,{children:e})]}),/* @__PURE__ */ (0,A.jsx)(`div`,{id:i,ref:a,className:`ui-md-details-body`,children:t})]})}function tx(e){let[t,n]=y.useState(null),[r,i]=y.useState(!1),[a,o]=y.useState(!1),s=y.useRef(null),c=()=>[...s.current?.querySelectorAll(`thead th`)??[]].map(e=>Math.ceil(e.getBoundingClientRect().width)),[l,u]=y.useState([]);y.useLayoutEffect(()=>{let e=s.current;if(!e)return;let t=()=>{let t=[...e.querySelectorAll(`thead th`)].map(e=>Math.ceil(e.getBoundingClientRect().width));u(e=>e.length===t.length&&e.every((e,n)=>e===t[n])?e:t)};t();let n=U(t);return n?.observe(e),()=>n?.disconnect()},[]);let d=r=>/* @__PURE__ */ (0,A.jsxs)(`table`,{ref:r?s:void 0,className:`ui-md-table`,style:r&&t?{width:t.reduce((e,t)=>e+t,0),tableLayout:`fixed`,minWidth:0}:void 0,children:[r&&t?/* @__PURE__ */ (0,A.jsx)(`colgroup`,{children:t.map((e,t)=>/* @__PURE__ */ (0,A.jsx)(`col`,{style:{width:e}},t))}):null,/* @__PURE__ */ (0,A.jsx)(`thead`,{children:/* @__PURE__ */ (0,A.jsx)(`tr`,{children:e.heads.map((i,a)=>/* @__PURE__ */ (0,A.jsxs)(`th`,{style:e.align(a),children:[i,r?/* @__PURE__ */ (0,A.jsx)(cy,{name:e.headText[a],width:t?.[a]??l[a]??0,start:()=>(t??c())[a],onWidth:e=>{let r=(t??c()).slice();r[a]=e,n(r)},onReset:()=>n(null),onDragging:o}):null]},a))})}),/* @__PURE__ */ (0,A.jsx)(`tbody`,{children:e.rows.map((t,n)=>/* @__PURE__ */ (0,A.jsx)(`tr`,{children:t.map((t,n)=>/* @__PURE__ */ (0,A.jsx)(`td`,{className:e.numeric[n]?`is-num`:void 0,style:e.align(n),"data-label":e.headText[n],children:t},n))},n))})]});return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-md-tablebox`,a&&`is-resizing`),children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-md-table-tools`,children:/* @__PURE__ */ (0,A.jsx)(ly,{onClick:()=>i(!0)})}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-md-table-wrap`,tabIndex:0,role:`region`,"aria-label":e.label,children:d(!0)}),/* @__PURE__ */ (0,A.jsx)(uy,{open:r,onClose:()=>i(!1),children:/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-md ui-md-table-wrap`,tabIndex:0,role:`region`,"aria-label":e.label,children:d(!1)})})]})}xe(),Ce(),Fe(),ti(be,Se,Pe);let nx=y.createContext(null),rx=()=>typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;function ix(e){if(e)try{let t=localStorage.getItem(`ui-section:`+e);return t===`1`||t!==`0`&&void 0}catch{return}}function ax(e,t){if(e)try{localStorage.setItem(`ui-section:`+e,t?`1`:`0`)}catch{}}function ox(e){let t=y.useContext(nx),n=y.useId(),[r,i]=y.useState(()=>ix(e.storageKey)??e.defaultOpen??!1),a=e.open??r,o=y.useCallback(t=>{e.open===void 0&&i(t),ax(e.storageKey,t),e.onOpenChange?.(t)},[e.open,e.storageKey,e.onOpenChange]),s=y.useRef(o),c=y.useRef(a);y.useLayoutEffect(()=>{s.current=o,c.current=a});let[l,u]=y.useState(a),[d,f]=y.useState(!1);l!==a&&(u(a),f(!a)),y.useEffect(()=>{if(!d)return;let e=window.setTimeout(()=>f(!1),rx()?0:260);return()=>window.clearTimeout(e)},[d]);let p=y.useRef(null);y.useEffect(()=>{let t=p.current;if(!t||e.lazy)return;if(a){t.removeAttribute(`hidden`);return}let n=window.setTimeout(()=>t.setAttribute(`hidden`,`until-found`),rx()?0:260),r=()=>s.current(!0);return t.addEventListener(`beforematch`,r),()=>{window.clearTimeout(n),t.removeEventListener(`beforematch`,r)}},[a,e.lazy]);let m=y.useRef(null);y.useEffect(()=>{if(!e.id)return;let t=()=>{decodeURIComponent(location.hash.slice(1))===e.id&&(c.current||s.current(!0),requestAnimationFrame(()=>m.current?.scrollIntoView?.({block:`start`,behavior:rx()?`auto`:`smooth`})))};return t(),window.addEventListener(`hashchange`,t),()=>window.removeEventListener(`hashchange`,t)},[e.id]);let h=y.useRef(t?.all.n??0);y.useEffect(()=>{t&&t.all.n!==h.current&&(h.current=t.all.n,t.all.open!==c.current&&s.current(t.all.open))},[t,t?.all.n,t?.all.open]);let g=t?.report;y.useEffect(()=>{g?.(n,a)},[g,n,a]),y.useEffect(()=>()=>g?.(n,null),[g,n]);let _=`h${e.level??3}`,v=n+`-body`,b=!e.lazy||a||d;return/* @__PURE__ */ (0,A.jsxs)(`section`,{id:e.id,className:M(`ui-sec`,a&&`is-open`,e.className),children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-sec-row`,children:[/* @__PURE__ */ (0,A.jsx)(_,{ref:m,className:`ui-sec-h`,children:/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:`ui-sec-btn`,"aria-expanded":a,"aria-controls":v,onClick:()=>o(!a),children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-right`,size:18,className:`ui-sec-caret`}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-sec-title`,children:e.title}),e.summary!=null&&e.summary!==!1?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-sec-sum`,children:e.summary}):null]})}),e.actions?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-sec-actions`,children:e.actions}):null]}),/* @__PURE__ */ (0,A.jsx)(`div`,{id:v,className:`ui-sec-body`,children:/* @__PURE__ */ (0,A.jsx)(`div`,{ref:p,className:`ui-sec-in`,children:b?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-sec-content`,children:e.children}):null})})]})}function sx({children:e,actions:t,bar:n=!0,className:r}){let[i,a]=y.useState({n:0,open:!1}),[o,s]=y.useState({}),c=y.useCallback((e,t)=>{s(n=>t===null?e in n?Object.fromEntries(Object.entries(n).filter(([t])=>t!==e)):n:n[e]===t?n:{...n,[e]:t})},[]),l=y.useCallback(e=>a(t=>({n:t.n+1,open:e})),[]),u=Object.values(o),d=u.length===0||u.some(e=>!e),f=y.useMemo(()=>({all:i,report:c,anyClosed:d,setAll:l}),[i,c,d,l]);return/* @__PURE__ */ (0,A.jsx)(nx.Provider,{value:f,children:/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-sec-group`,r),children:[n?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-sec-bar`,children:[t??null,/* @__PURE__ */ (0,A.jsx)(cx,{})]}):null,e]})})}function cx({className:e}){let t=y.useContext(nx);if(!t)return null;let n=t.anyClosed;return/* @__PURE__ */ (0,A.jsx)(np,{className:M(`ui-sec-toggle`,e),icon:n?`arrows-out-line-vertical`:`arrows-in-line-vertical`,label:w(n?`全部展開`:`全部收合`),onClick:()=>t.setAll(n)})}function lx(e){return e.split(/([\u2e80-\u9fff\uff00-\uffef]+)/).map((e,t)=>t%2?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-kpi-cjk`,children:e},t):e)}function ux(e){let{label:t,value:n,unit:r,decimals:i=0,delta:a,deltaUnit:o,good:s,spark:c,compareLabel:l,size:u=`default`,verdict:d,target:f,className:p}=e,m=u===`compact`;G(m&&!!c,`KpiCard`,`size="compact" 不畫迷你折線,spark 會被忽略。拿掉 spark,或改用一般大小。`),G(e.format===`percent`&&!r,`KpiCard`,`format='percent' shows the number only; pass unit="%" for the smaller % after it.`);let h=v_(n,900),g=y.useRef(null);T_(g,[n,e.format,r,i,e.compact,e.currency,S.locale]);let _=typeof a==`number`,v=_&&a>0,b=s??v,x=_?o===`pt`?w(`{n} 個百分點`,{n:p_.number(Math.abs(a),2)}):p_.percent(Math.abs(a)):``,C=null;if(!m&&c&&c.length>1){let e=Math.max(...c),t=Math.min(...c);C=b_(c.map((n,r)=>[r*160/(c.length-1),32-(n-t)/(e-t||1)*28]))}let T=r&&e.format!==`money`;return/* @__PURE__ */ (0,A.jsxs)(`section`,{className:M(`ui-kpi`,m&&`is-compact`,p),children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-kpi-label`,children:t}),/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:g,className:`ui-kpi-value`,"aria-label":w_(n,e,i)+(T?` `+r:``),children:[/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-kpi-num`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-kpi-sizer`,children:lx(w_(n,e,i))}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-kpi-live`,children:lx(w_(n*h,e,i))})]}),T?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-kpi-unit`,"aria-hidden":`true`,children:r}):null]}),C?/* @__PURE__ */ (0,A.jsx)(`svg`,{className:`ui-kpi-spark`,width:`100%`,height:36,viewBox:`0 0 160 36`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(`path`,{d:C,fill:`none`,stroke:`var(--chart-1)`,strokeWidth:2,strokeLinecap:`round`,vectorEffect:`non-scaling-stroke`})}):null,_?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-kpi-delta`,children:[/* @__PURE__ */ (0,A.jsxs)(`span`,{className:M(`ui-kpi-change`,b?`is-good`:`is-bad`),children:[v?`▲ `:`▼ `,ne(x)]}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-kpi-note`,children:l||w(`較上週`)})]}):null,d||f?d&&d.tone!==`success`?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-kpi-target ui-kpi-verdict is-`+d.tone,children:im(f?w(`{v}({t})`,{v:d.text,t:f}):d.text)}):/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-kpi-target`,children:[d?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:im(d.text+w(`,`))}):null,im(f)]}):null]})}function dx({checked:e,onChange:t,label:n,disabled:r,className:i}){let a=!!e,[o,s]=y.useState(!1),c=o?28:a?24:16,l=(28-c)/2,u=o?6:0,d=a?48-l-c-u:l,f=a?l:48-l-c-u;return/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":a,"aria-label":n,disabled:r,className:M(`ui-switch`,a&&`is-on`,i),onClick:()=>t?.(!a),onPointerDown:()=>s(!0),onPointerUp:()=>s(!1),onPointerLeave:()=>s(!1),onPointerCancel:()=>s(!1),children:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-switch-thumb`,style:{left:d,right:f,height:c,marginTop:-c/2,transition:`${hi(`left`,`right`,a)}, height var(--dur-hover) ease, margin-top var(--dur-hover) ease, background-color var(--dur-nav) ease`},children:/* @__PURE__ */ (0,A.jsx)(`svg`,{width:12,height:12,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:3.5,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(`path`,{d:a?`M5 12.5l4.5 4.5L19 7`:`M7 7l10 10M17 7L7 17`})})})})}on(),Or(),ti(an,Dr);let fx=/* @__PURE__ */ new Map,px,mx=/(\d[\d,.]*)/;function hx(e){return Qp(e).flatMap(e=>e.code?[{mono:!0,text:e.text}]:e.text.split(mx).map((e,t)=>({mono:t%2==1,text:e})).filter(e=>e.text!==``))}function gx(e,t,n){if(typeof e==`function`){let n=e(t);for(let e of[p_.number(t),String(t)])if(n.includes(e))return n.replace(e,``);return n}return(e??n(t)).replace(`{n}`,``)}function _x(e,t,n){let r=e===1?w(t):``;return r&&r!==t?r:w(n)}function vx(e){e.currentTarget.matches(`:focus-visible`)&&e.currentTarget.scrollIntoView?.({block:`nearest`,inline:`nearest`})}function yx(){return typeof CanvasRenderingContext2D==`function`?document.createElement(`canvas`).getContext(`2d`):null}function bx(e,t,n){px===void 0&&(px=yx());let r=px;if(!r)return e.length*t*.6;let i=getComputedStyle(document.documentElement);return r.font=`600 ${t}px `+((n?i.getPropertyValue(`--font-mono`):i.getPropertyValue(`--font-sans`))||`sans-serif`),r.measureText(e).width}function xx(e){let[t,n]=y.useState(!1),r=y.useRef(null);return/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-lg-resize`,t&&`is-dragging`),role:`separator`,"aria-orientation":`horizontal`,"aria-label":w(`調整架構圖高度`),"aria-valuenow":e.value,"aria-valuemin":e.min,"aria-valuemax":e.max,"aria-valuetext":w(`{n} px`,{n:e.value}),tabIndex:0,onPointerDown:t=>{t.button===0&&(t.preventDefault(),t.currentTarget.setPointerCapture?.(t.pointerId),r.current={y:t.clientY,d:e.start()},n(!0))},onPointerMove:t=>{r.current&&e.onDrag(r.current.d+t.clientY-r.current.y)},onPointerUp:()=>{r.current=null,n(!1)},onPointerCancel:()=>{r.current=null,n(!1)},onDoubleClick:e.onReset,onKeyDown:t=>{t.altKey||t.metaKey||t.ctrlKey||(t.key===`ArrowUp`||t.key===`ArrowDown`?(t.preventDefault(),e.onKey(t.key===`ArrowUp`?-16:16)):t.key===`Enter`&&(t.preventDefault(),e.onReset()))},children:/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-lg-resize-grip`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsx)(`i`,{}),/* @__PURE__ */ (0,A.jsx)(`i`,{}),/* @__PURE__ */ (0,A.jsx)(`i`,{})]})})}function Sx(e){let t=hx(e);px===void 0&&(px=yx());let n=px;if(!n)return e.length*9;let r=getComputedStyle(document.documentElement),i=r.getPropertyValue(`--font-sans`)||`sans-serif`,a=r.getPropertyValue(`--font-mono`)||`monospace`;return t.reduce((e,t)=>(n.font=`600 12px `+(t.mono?a:i),e+n.measureText(t.text).width),0)}let Cx=`ui-lg-labels:`,wx=e=>e.map(e=>e.id).join(`|`);function Tx(e){let t=[];for(let n of e.match(/`[^`]+`|[A-Za-z0-9_./:#@-]+|\s+|[\s\S]/gu)??[]){let e=t[t.length-1],r=/\d\s*$/.test(e??``)&&!/^[A-Za-z0-9_]/.test(n);e!=null&&(r||/^[)」』、,。:;!?)\],;!?]/.test(n)||/[(「『([]$/.test(e))?t[t.length-1]=e+n:t.push(n)}let n=e=>{let n=[],r=``;for(let i of t)/^\s+$/.test(i)?r&&(r+=i):r&&Sx(r.trimEnd()+i)>e?(n.push(r.trimEnd()),r=i):r+=i;return r.trim()&&n.push(r.trimEnd()),n},r=Sx(e),i=[[e]];for(let e=2;e<=4;e++){let a=Math.max(...t.filter(e=>e.trim()).map(Sx))-1,o=r;for(;o-a>1;){let t=(a+o)/2;n(t).length<=e?o=t:a=t}let s=n(o);s.length>i[i.length-1].length&&i.push(s)}return i}function Ex(e){return hx(e).map((e,t)=>e.mono?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-lg-code`,children:e.text},t):e.text)}function Dx(e,t){let n=`M${e[0][0]} ${e[0][1]}`;for(let r=1;r<e.length-1;r++){let[i,a,o]=[e[r-1],e[r],e[r+1]],s=Math.min(t,Math.abs(a[0]-i[0]+a[1]-i[1])/2,Math.abs(o[0]-a[0]+o[1]-a[1])/2),c=Math.sign(a[0]-i[0]),l=Math.sign(a[1]-i[1]),u=Math.sign(o[0]-a[0]),d=Math.sign(o[1]-a[1]);n+=` L${a[0]-c*s} ${a[1]-l*s} Q${a[0]} ${a[1]} ${a[0]+u*s} ${a[1]+d*s}`}let r=e[e.length-1];return`${n} L${r[0]} ${r[1]}`}let Ox=e=>e.filter((t,n)=>{let r=e[n-1];return!r||r[0]!==t[0]||r[1]!==t[1]}).filter((e,t,n)=>{let r=n[t-1],i=n[t+1];return!r||!i||!(r[0]===e[0]&&e[0]===i[0]||r[1]===e[1]&&e[1]===i[1])});function kx(e){let[t,n]=y.useState(0),[r,i]=y.useState(null),a=r&&r.at===t?r:null,o=a?.nw??(e.nodeWidth||200),[s,c]=y.useState(()=>{if(!e.resizable||!e.heightKey)return 0;try{let t=Number(localStorage.getItem(`ui-lg-height:`+e.heightKey));return Number.isFinite(t)?t:0}catch{return 0}}),l=y.useCallback(t=>{if(c(t),e.heightKey)try{localStorage.setItem(`ui-lg-height:`+e.heightKey,String(Math.round(t)))}catch{}},[e.heightKey]),u=t+`#`+e.nodes.map(e=>e.id).join(`|`)+`#`+e.edges.map(e=>e.from+`>`+e.to+`:`+(e.label??``)).join(`|`),[d,f]=y.useState({key:``,n:0}),p=d.key===u?d.n:0,m=(a?.col??40)+p*24,h=a?.scale??1,g=e.nodes,_=e.selected??null;G(g.some(e=>e.fns!=null),`LayerGraph`,`fns is renamed size; pass size and, for the text under the bar, sizeLabel such as 「{n} 個函式」.`),G(g.some(e=>e.external&&e.shared),`LayerGraph`,`a node is both external and shared; it is drawn as shared. Keep one of the two.`);let v=e=>e.external&&!e.shared?void 0:e.size??e.fns,b=new Set(g.filter(e=>e.shared).map(e=>e.id)),x=g.filter(e=>!e.shared),S=x.some(e=>{if(!e.tag)return!1;let t=e.name||e.id,n=bx(e.tag,12,!1)+12+(e.tagTone===`warning`?15:0);return o-(e.external?24:28)-6-n<bx(t.slice(0,8),13,!!e.code)+ +(t.length>8)}),C=S?76:60,T=g.filter(e=>e.shared),E=e.edges.filter(e=>!b.has(e.from)&&!b.has(e.to)),D=e=>!!(e.inferred||e.declared),O=/* @__PURE__ */ new Map,k=-1/0;for(let e of x){let t=e.external?k:e.layer||0;O.set(t,[...O.get(t)??[],e])}let j=[...O.keys()].sort((e,t)=>e-t),N=Math.max(1,...j.map(e=>O.get(e)?.length??0)),P=32+N*o+(N-1)*m,I=Math.max(0,j.length-1),L=e.resizable&&s>0&&I?Math.min(200,s/h/I):0,R=j.map((e,t)=>56+(t<I?L:0)),z=0,B={},V={};j.forEach((e,t)=>{let n=O.get(e)??[],r=(P-(n.length*o+(n.length-1)*m))/2;n.forEach((e,n)=>{B[e.id]={x:r+n*(o+m),y:0},V[e.id]=t})});let H=e=>16+e*C+R.slice(0,e).reduce((e,t)=>e+t,0),ee=O.get(k)??[],te=Math.max(o,Math.min(e.nodeWidth||200,P-16)),ne=e=>{let t=ee.length===1&&ee[0].id===e?te:o;return{x:B[e].x+(o-t)/2,w:t}},W=()=>{for(let e in B)B[e].y=H(V[e]);z=H(j.length-1)+C+16+(oe[j.length-1]?.length?ue:0)},re=Math.max(1,...x.map(e=>v(e)||0)),ie=Math.max(1,...E.map(e=>e.count||0)),K=e=>!!B[e.from]&&!!B[e.to]&&V[e.to]<V[e.from],q=e=>!!B[e.from]&&!!B[e.to]&&e.from!==e.to&&V[e.to]===V[e.from],ae={},oe={},se={},ce={},le={},J={};for(let e of E)B[e.from]&&B[e.to]&&(K(e)?((le[e.from]??=[]).push(e),(J[e.to]??=[]).push(e)):((se[e.from]??=[]).push(e),q(e)?((ae[e.to]??=[]).push(e),(oe[V[e.from]]??=[]).push(e)):(ce[e.to]??=[]).push(e)));let ue=20+10*Math.max(0,(oe[j.length-1]?.length??0)-1),de=E.filter(K),fe=e=>O.get(j[V[e]])??[],pe=e=>fe(e)[fe(e).length-1]?.id===e,me=e=>fe(e)[0]?.id===e,he=e=>!pe(e.to)&&me(e.to),ge=de.filter(he),_e=de.filter(e=>!he(e));for(let e in se)se[e].sort((e,t)=>B[e.to].x-B[t.to].x);for(let e in ce)ce[e].sort((e,t)=>B[e.from].x-B[t.from].x);let ve=e=>e.id??`${e.from}->${e.to}`,ye=e.onSelectEdge,[be,xe]=y.useState(()=>{try{let t=window.localStorage.getItem(Cx+(e.scrollKey??wx(e.nodes)));if(t===`1`||t===`0`)return t===`1`}catch{}return e.edgeLabels!==`hover`}),Se=!be,Ce=()=>{let t=!be;xe(t);try{window.localStorage.setItem(Cx+(e.scrollKey??wx(e.nodes)),t?`1`:`0`)}catch{}},[we,Te]=y.useState(null),{ref:Ee,more:De,overflows:Oe,scrolled:ke,onScroll:Ae}=oy(),je=y.useId().replace(/:/g,``),[Me,Ne]=y.useState(`graph`),Pe=e.scrollKey??g.map(e=>e.id).join(`|`);y.useLayoutEffect(()=>{let e=Ee.current,t=fx.get(Pe);e&&t&&(e.scrollLeft=t)},[Pe,Me,Ee]);let Fe=()=>{let e=Ee.current;e&&fx.set(Pe,e.scrollLeft),Ae()},Ie=ye&&E.find(t=>ve(t)===e.selectedEdge)||null,Le=ye&&e.edges.find(t=>ve(t)===e.selectedEdge)||null,Re=new Set(g.map(e=>e.id)),ze={};for(let t of e.edges)b.has(t.to)&&t.from!==t.to&&Re.has(t.from)&&((ze[t.to]??={})[t.from]=(ze[t.to]?.[t.from]??0)+(t.count||0));let Be=!Ie&&_!=null&&b.has(_)?_:null,Ve=e=>Ie?e===Ie:!!_&&!Be&&(e.from===_||e.to===_),He=!!_||!!Ie,Ue=e=>Ie?e===Ie.from||e===Ie.to:Be?e===Be||e in(ze[Be]??{}):!_||e===_||E.some(t=>Ve(t)&&(t.from===e||t.to===e)),We=(t,n)=>{!n&&e.selectedEdge!=null&&ye?.(null),e.onSelect?.(n?null:t)},Ge=e=>g.find(t=>t.id===e)?.name||e,Ke=t=>{let n=t.count??0;return typeof e.countLabel==`function`?e.countLabel(n):(e.countLabel??_x(n,`1 次`,`{n} 次`)).replace(`{n}`,p_.number(n))},qe=e=>/^[A-Z][a-z]/.test(e)&&!/^zh/i.test(p_.locale())?e[0].toLowerCase()+e.slice(1):e,Je=/* @__PURE__ */ new Map;for(let e of E)D(e)&&e.label&&B[e.from]&&B[e.to]&&Je.set(e.label,(Je.get(e.label)??0)+1);let Ye=t=>t.declared?e.declaredLabel||w(`宣告`):e.inferredLabel||w(`推測`),Xe=e=>e.label&&(Je.get(e.label)??0)>1?w(`來自 {from},{label}`,{from:Ge(e.from),label:qe(e.label)}):e.label||Ye(e),Ze=e=>D(e)?Xe(e):Ke(e);if(ge.length){let e=Math.min(...x.map(e=>B[e.id].x)),t=Math.max(0,16+(ge.length-1)*12+20-e);for(let e in B)B[e]={x:B[e].x+t,y:B[e].y};P+=t}let Qe=()=>Math.min(...x.map(e=>B[e.id].x)),$e=()=>Math.max(0,...x.map(e=>B[e.id].x+o)),et=e=>he(e)?Qe()-20-ge.indexOf(e)*12:$e()+20+_e.indexOf(e)*12,tt=()=>Qe()-20+8,nt=()=>$e()+20-8;_e.length&&(P=Math.max(P,$e()+20+(_e.length-1)*12+16));let rt=t=>{let n=ve(t),r=e.selectedEdge===n?null:n;r&&_!=null&&e.onSelect?.(null),ye?.(r)},it=e=>Math.round(B[e.to].x+o*(ce[e.to].indexOf(e)+1)/(ce[e.to].length+1)),at={},ot={};{let e={};for(let t of E)ce[t.to]?.includes(t)&&(D(t)||Ve(t))&&(e[t.to]??=[]).push(t);for(let t in e)e[t].length<2||(at[t]=e[t].sort((e,t)=>it(t)-it(e)),ot[t]=e[t].length)}let st=()=>{let e=[],t=[],n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set,i=0,a=e=>{let t=B[e.from],n=B[e.to],r=se[e.from].indexOf(e),i=se[e.from].length,a=c(t.x,r,i),s=t.y+C,l=it(e),u=n.y,d=(r-(i-1)/2)*6,f=V[e.to]-V[e.from]>1,p=s+R[V[e.from]]/2+d,h=a;if(f){let t=(O.get(j[V[e.from]+1])??[]).map(e=>B[e.id]),n=(a+l)/2,r=[t[0].x-m/2,...t.map(e=>e.x+o+m/2)].map(e=>Math.max(8,Math.min(P-8,e)));h=r.reduce((e,t)=>Math.abs(t-n)<Math.abs(e-n)?t:e,r[0])+d}return{sx:a,sy:s,tx:l,ty:u,off:d,skip:f,y1:p,chx:h,from:f?h:a,startY:f?p:s}},s=/* @__PURE__ */ new Map,c=(e,t,n)=>Math.round(n<2?e+o/2:e+16+(o-32)*t/(n-1)),l=e=>{let t=B[e.from],n=B[e.to],r=se[e.from].indexOf(e),i=se[e.from].length,a=c(t.x,r,i),s=oe[V[e.from]].indexOf(e),l=ae[e.to].indexOf(e),u=Math.round(n.x+o-24-l*12);return{sx:a,sy:t.y+C,y:t.y+C+14+s*10,tx:u,ty:n.y+C}},u=e=>{if(q(e)){let t=l(e);return[{x:t.sx,y0:t.sy,y1:t.y},{x:t.tx,y0:t.ty,y1:t.y}]}if(K(e))return[{x:et(e),y0:B[e.to].y,y1:B[e.from].y+C}];let t=a(e);if(!t.skip)return[{x:t.sx,y0:t.sy,y1:t.y1},{x:t.tx,y0:t.y1,y1:t.ty}];let n=t.ty-R[V[e.to]-1]/2+t.off;return[{x:t.sx,y0:t.sy,y1:t.y1},{x:t.chx,y0:t.y1,y1:n},{x:t.tx,y0:n,y1:t.ty}]};for(let e in at){let t=at[e].map(e=>({e,g:a(e),w:Math.ceil(Sx(Ze(e)))})),n=E.filter(t=>!at[e].includes(t)&&B[t.from]&&B[t.to]).flatMap(e=>u(e).map(e=>({k:-1,...e}))),r=t.length,i=e=>t[0].g.ty-8-16-e*28,o=[],c=(e,t)=>{e.length?e.forEach((n,r)=>c([...e.slice(0,r),...e.slice(r+1)],[...t,n])):o.push(t)};r<=6?c([...t.keys()],[]):o.push([...t.keys()]);let l=null;for(let e of o){let r=[];e.forEach((e,t)=>r[e]=i(t));let a=[...t.flatMap((e,t)=>[{k:t,x:e.g.from,y0:e.g.startY,y1:r[t]},{k:t,x:e.g.tx,y0:r[t],y1:e.g.ty-8}]),...n],o=(e,t,n)=>a.every(i=>i.k===e?!(i.x>t-1&&i.x<n+1&&i.y0<r[e]+7&&i.y1>r[e]-7):!(i.x>t-5&&i.x<n+5&&i.y0<r[e]+10&&i.y1>r[e]-10)),s=0,c=[];if(t.forEach((e,t)=>{let n=Math.max(e.g.from,e.g.tx)+8,r=Math.min(e.g.from,e.g.tx)-8;o(t,n,n+e.w)?c[t]=`right`:o(t,r-e.w,r)?c[t]=`left`:(c[t]=`right`,s++)}),(!l||s<l.fails)&&(l={fails:s,ys:r,sides:c}),!s)break}l&&t.forEach((e,t)=>s.set(e.e,{y:l.ys[t],side:l.sides[t]}))}let d=[],f=0,p=0,h=[],g=[],_={},v=[],b=[];E.forEach((t,n)=>{let r=B[t.from],i=B[t.to];if(!r||!i)return;let c=Ve(t),u=He&&!c,f=t===Ie,p=!!ye&&we===ve(t)&&!c,m=K(t),y,x,S,T,E=1,O=null,k=0,j=`right`;if(m){let e=et(t),a=he(t),s=le[t.from].indexOf(t),l=le[t.from].length,f=J[t.to].indexOf(t),p=J[t.to].length,m=[],g;if(a?me(t.from):pe(t.from))g=Math.round(r.y+C/2+(s-(l-1)/2)*10),m.push([a?r.x:r.x+o,g],[e,g]);else{let t=a?r.x+20+s*10:r.x+o-20-s*10;g=r.y-12-s*6,m.push([t,r.y],[t,g],[e,g])}let _;if(a||pe(t.to)){_=Math.round(i.y+C/2+(f-(p-1)/2)*10),x=a?i.x:i.x+o,S=_;let t=a?x-9:x+9;y=[...m,[e,_],[t,_]],T=`M${t} ${S-5} L${t} ${S+5} L${x} ${S} Z`,v.push([Math.min(x,t),Math.max(x,t),S-5,S+5]),h.push([Math.min(x,e),Math.max(x,e),_-3,_+3])}else x=i.x+o-20-f*10,_=i.y+C+12+f*6,S=i.y+C,y=[...m,[e,_],[x,_],[x,S+9]],T=`M${x-5} ${S+9} L${x+5} ${S+9} L${x} ${S} Z`,v.push([x-5,x+5,S,S+9]),h.push([x,e,_-3,_+3]);let b=m[m.length-2][0];if(h.push([Math.min(b,e),Math.max(b,e),g-3,g+3]),D(t)||c){let e=Ze(t);d.push({idx:n,e:t,text:e,tx:a?tt():nt(),ty:Math.round((g+_)/2),left:!a,r:c,dim:u,up:!0})}}else if(q(t)){let e=l(t);if(x=e.tx,S=e.ty,y=[[e.sx,e.sy],[e.sx,e.y],[e.tx,e.y],[e.tx,e.ty+9]],T=`M${x-5} ${S+9} L${x+5} ${S+9} L${x} ${S} Z`,v.push([x-5,x+5,S,S+9]),h.push([Math.min(e.sx,e.tx),Math.max(e.sx,e.tx),e.y-3,e.y+3]),D(t)||c){let r=Ze(t);d.push({idx:n,e:t,text:r,tx:Math.round((e.sx+e.tx)/2),ty:e.y,left:!1,r:c,dim:u,flat:!0})}}else{E=ce[t.to].length;let e=a(t),{sx:n,sy:r,skip:i}=e;x=e.tx,S=e.ty;let o=s.get(t),c=o?o.y:null,l=!i&&c!=null?c:e.y1;if(i){let i=c??S-R[V[t.to]-1]/2+e.off;y=[[n,r],[n,l],[e.chx,l],[e.chx,i],[x,i],[x,S-8]]}else y=[[n,r],[n,l],[x,l],[x,S-8]];k=e.from,O=c,j=o?.side??`right`,T=`M${x-5} ${S-9} L${x+5} ${S-9} L${x} ${S} Z`,v.push([x-5,x+5,S-9,S])}let N=(D(t)?1.5:1.5+5.5*((t.count||0)/ie))+(f?1.5:0)+(p?2:0),P=Ox(y);_[n]=P;for(let e=1;e<P.length;e++){let[t,r]=P[e-1],[i,a]=P[e];g.push({idx:n,box:[Math.min(t,i)-3,Math.max(t,i)+3,Math.min(r,a)-3,Math.max(r,a)+3]})}let F=Dx(P,10);if(e.push(/* @__PURE__ */ (0,A.jsx)(`path`,{className:M(`ui-lg-edge`,t.declared?`is-declared`:t.inferred&&`is-inferred`,c&&`is-related`,u&&`is-dim`,p&&`is-hover`),d:F,strokeWidth:N},`p`+n)),!ye&&Se&&b.push(/* @__PURE__ */ (0,A.jsx)(`path`,{className:`ui-lg-hit is-peek`,d:F,onPointerEnter:()=>Te(ve(t)),onPointerLeave:()=>Te(null)},`h`+n)),ye&&b.push(/* @__PURE__ */ (0,A.jsx)(`path`,{className:`ui-lg-hit`,"data-edge":ve(t),d:F,role:`button`,tabIndex:0,"aria-label":w(`{from} 到 {to},{what}`,{from:Ge(t.from),to:Ge(t.to),what:Ze(t).replace(/`/g,``)}),"aria-pressed":f,onClick:e=>{e.stopPropagation(),rt(t)},onPointerEnter:()=>Te(ve(t)),onPointerLeave:()=>Te(null),onFocus:Se?()=>Te(ve(t)):void 0,onBlur:Se?()=>Te(null):void 0,onKeyDown:e=>{e.key===`Enter`||e.key===` `?(e.preventDefault(),rt(t)):e.key===`Escape`&&f&&ye(null)}},`h`+n)),e.push(/* @__PURE__ */ (0,A.jsx)(`path`,{className:M(`ui-lg-arrow`,c&&`is-related`,u&&`is-dim`),d:T},`a`+n)),!m&&!q(t)&&(D(t)||c)){let e=Ze(t);d.push({idx:n,e:t,text:e,tx:x,ty:S,left:E>1&&x<i.x+o/2,r:c,dim:u,lane:O,from:k,side:j})}});let S=[...v,...h],T=x.map(e=>[ne(e.id).x,ne(e.id).x+ne(e.id).w,B[e.id].y,B[e.id].y+C]),k=(e,t,n,r)=>S.some(i=>e<i[1]+(i[4]||0)&&i[0]<t+(i[4]||0)&&n<i[3]&&i[2]<r),N=(e,t,n,r,i)=>t<e[1]-1&&e[0]+1<t+n&&r<e[3]-1&&e[2]+1<i,F=(e,t,n,r,i)=>Math.hypot(Math.max(0,e[0]-(t+n),t-e[1]),Math.max(0,e[2]-i,r-e[3])),I=(e,t,n,r,i)=>{let a=1/0,o=1/0;for(let s of g){let c=F(s.box,t,n,r,i);s.idx===e?a=Math.min(a,c):o=Math.min(o,c)}return a+4<o&&o>=8},L=(e,t=!0)=>{let n=_[e.idx]??[],r=(t,n,r,i)=>I(e.idx,t,n,r,i),i=(n,i,a,o)=>(!t||r(n,i,a,o))&&n>=8&&n+i<=P-8&&a>=2&&o<=z-2&&!k(n-2,n+i+2,a-2,o+2)&&!T.some(e=>n<e[1]+4&&e[0]<n+i+4&&a<e[3]+4&&e[2]<o+4)&&!g.some(t=>t.idx===e.idx?N(t.box,n,i,a,o):n<t.box[1]+2&&t.box[0]<n+i+2&&a<t.box[3]+2&&t.box[2]<o+2);for(let t of Tx(e.text)){let r=Math.ceil(Math.max(...t.map(Sx))),a=t.length*16,o=null;for(let t=1;t<n.length;t++){let[s,c]=n[t-1],[l,u]=n[t],d=Math.hypot(l-s,u-c);for(let t=0;t<=d;t+=6){let n=s+(l-s)*t/d,f=c+(u-c)*t/d,p=s===l?[[n+8,f],[n-8-r,f]]:[[n-r/2,f-6-a/2],[n-r/2,f+6+a/2]];for(let[t,n]of p){let s=Math.hypot(t+r/2-e.tx,n-e.ty);o&&s>=o.d||i(t,r,n-a/2,n+a/2)&&(o={x0:t,top:n,d:s})}}}if(o)return{x0:Math.round(o.x0),top:Math.round(o.top),lw:r,lh:a,lines:t}}return null},U=[],ee=(e,t)=>{let n=_[e.idx]??[],r=t.x0+t.lw/2,i=t.top,a=null;for(let t=0;t+1<n.length;t++){let[o,s]=n[t],[c,l]=n[t+1],u=Math.hypot(c-o,l-s);for(let t=12;t<=u-12;t+=4){let n=o+(c-o)*t/u,d=s+(l-s)*t/u,f=!g.some(t=>t.idx!==e.idx&&F(t.box,n-14,28,d-14,d+14)===0)&&!T.some(e=>n+14>e[0]&&n-14<e[1]&&d+14>e[2]&&d-14<e[3])&&!k(n-14,n+14,d-14,d+14)&&!U.some(e=>Math.hypot(e.x-n,e.y-d)<28),p=Math.hypot(n-r,d-i);(!a||f&&!a.clear||f===a.clear&&p<a.d)&&(a={x:n,y:d,d:p,clear:f})}}let o=a??{x:e.tx,y:e.ty-20};return U.push({n:U.length+1,m:e,x:Math.round(o.x),y:Math.round(o.y)}),U.length},te=(e,t,n,r=[e.text],i=!1,a=0)=>/* @__PURE__ */ (0,A.jsx)(`span`,{"aria-hidden":ye?!0:void 0,className:M(`ui-lg-label`,i&&`is-over`,a>0&&`is-numbered`,a>0&&(we===ve(e.e)||e.e===Ie)&&`is-shown`,ye&&`is-clickable`,ye&&we===ve(e.e)&&`is-hover`,e.r&&`is-related`,e.dim&&`is-dim`,Se&&!e.r&&we!==ve(e.e)&&e.e!==Ie&&`is-quiet`),style:{left:t,top:n},onClick:ye?t=>{t.stopPropagation(),rt(e.e)}:void 0,onPointerEnter:ye?()=>Te(ve(e.e)):void 0,onPointerLeave:ye?()=>Te(null):void 0,children:r.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(y.Fragment,{children:[t?/* @__PURE__ */ (0,A.jsx)(`br`,{}):null,Ex(e)]},t))},`l`+e.idx),W=[],re=(e,a)=>{let o=Math.ceil(Sx(e.text));if(e.flat){let r=L(e);if(!r){let a=V[e.e.from];a<j.length-1&&n.add(a),i++;let s=Math.max(8,Math.min(P-8-o,e.tx-o/2)),c=e=>k(s,s+o,e-10,e+10)||T.some(t=>s<t[1]+2&&t[0]<s+o+2&&e-10<t[3]&&t[2]<e+10),l=e.ty+14;for(let e=0;e<8&&c(l);e++)l+=18;r={x0:s,top:l,lw:o,lh:16,lines:[e.text]},t.push(te(e,r.x0,r.top,r.lines,!0,ee(e,r)));return}S.push([r.x0,r.x0+r.lw,r.top-r.lh/2-4,r.top+r.lh/2+4,6]),t.push(te(e,r.x0,r.top,r.lines));return}if(e.up){let a=_[e.idx]?.[0],s=a?L({...e,tx:a[0],ty:a[1]},!0):null;if(s){S.push([s.x0,s.x0+s.lw,s.top-s.lh/2-4,s.top+s.lh/2+4,6]),t.push(te(e,s.x0,s.top,s.lines));return}let c=t=>Math.max(8,Math.min(P-8-t,e.left?e.tx-t:e.tx)),l=Math.max(10,Math.min(z-10,e.ty)),u=(t,n,r,i)=>{let a=(e,r,i)=>t<e[1]+4&&e[0]<t+n+4&&r<e[3]+4&&e[2]<i+4,o=(r,o)=>k(t,t+n,r-4,o+4)||T.some(e=>a(e,r,o))||i&&g.some(i=>i.idx===e.idx?N(i.box,t,n,r,o):a(i.box,r,o))||i&&!I(e.idx,t,n,r,o);for(let e=0;e<=16;e++)for(let t of e?[-1,1]:[0]){let n=l+t*e*18;if(n-r/2>=2&&n+r/2<=z-2&&!o(n-r/2,n+r/2))return n}return null},d=null;for(let t of Tx(e.text)){let e=Math.ceil(Math.max(...t.map(Sx))),n=t.length*16,r=c(e),i=u(r,e,n,!0);if(i!=null){d={x0:r,top:i,lw:e,lh:n,lines:t};break}}if(d||=L(e),!d){let a=Math.max(0,Math.min(j.length-2,j.findIndex((t,n)=>n<j.length-1&&e.ty<H(n+1))));n.add(a),i++;let s=c(o),d=u(s,o,16,!1);d??r.add(a);let f={x0:s,top:d??l,lw:o,lh:16,lines:[e.text]};t.push(te(e,f.x0,f.top,f.lines,!0,ee(e,f)));return}S.push([d.x0,d.x0+d.lw,d.top-d.lh/2-4,d.top+d.lh/2+4,6]),t.push(te(e,d.x0,d.top,d.lines));return}let s=V[e.e.to]-1,c=s>=0?H(s)+C:0,l=t=>{let n=e.left;return n&&e.tx-8-t<0?n=!1:!n&&e.tx+8+t>P&&(n=e.tx-8-t>=0),n},u=(t,n)=>t?e.tx-8-n:Math.min(e.tx+8,P-n),d=(t,n,r,i)=>{let a=e=>t<e[1]+2&&e[0]<t+n+2&&r<e[3]+2&&e[2]<i+2;return!k(t,t+n,r,i)&&!T.some(a)&&!g.some(o=>o.idx===e.idx?N(o.box,t,n,r,i):a(o.box))},m=null;if(e.lane!=null){let t=e.lane;for(let n of Tx(e.text)){if(m)break;let r=Math.ceil(Math.max(...n.map(Sx))),i=n.length*16,a=Math.max(e.tx,e.from??e.tx)+8,o=Math.min(e.tx,e.from??e.tx)-8-r;for(let s of e.side===`left`?[o,a]:[a,o])!m&&d(s,r,t-i/2,t+i/2)&&(m={x0:s,top:t,lw:r,lh:i,lines:n})}}for(let t of m?[]:Tx(e.text)){let n=Math.ceil(Math.max(...t.map(Sx))),r=t.length*16,i=l(n);for(let a of[i,!i]){let i=u(a,n);if(!(i<0||i+n>P)){for(let a=0;a<8&&!m;a++){let o=e.ty-8-r/2-a*18;if(o-r/2<Math.max(2,c+2))break;d(i,n,o-r/2,o+r/2)&&(m={x0:i,top:o,lw:n,lh:r,lines:t})}if(m)break}}if(m)break}if(m||=L(e),!m&&!a){W.push(e);return}let h=!m;if(!m){s>=0&&n.add(s),i++;let t=(e,t,n,r)=>!k(e,e+t,n,r)&&!T.some(i=>e<i[1]+2&&i[0]<e+t+2&&n<i[3]+2&&i[2]<r+2);for(let n of Tx(e.text)){let r=Math.ceil(Math.max(...n.map(Sx))),i=n.length*16,a=l(r);for(let o of[a,!a]){let a=u(o,r);if(!(a<0||a+r>P)){for(let o=0;o<8&&!m;o++){let s=e.ty-8-i/2-o*18;if(s-i/2<Math.max(2,c+2))break;t(a,r,s-i/2,s+i/2)&&(m={x0:a,top:s,lw:r,lh:i,lines:n})}if(m)break}}if(m)break}if(!m){s>=0&&r.add(s);let t=u(l(o),o),n=e.ty-16;for(let e=0;e<8&&k(t,t+o,n-8,n+8);e++)n-=18;m={x0:t,top:n,lw:o,lh:16,lines:[e.text]}}}h?t.push(te(e,m.x0,m.top,m.lines,!0,ee(e,m))):(S.push([m.x0,m.x0+m.lw,m.top-m.lh/2-4,m.top+m.lh/2+4,6]),f=Math.max(f,m.x0+m.lw+8+4),p=Math.min(p,m.x0-8-4),t.push(te(e,m.x0,m.top,m.lines,h)))};d.sort((e,t)=>Number(!!e.up)-Number(!!t.up)||e.ty-t.ty||e.tx-t.tx).forEach(e=>re(e,!1)),W.forEach(e=>re(e,!0));for(let e of U)t.push(/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-lg-num`,e.m.dim&&`is-dim`,(we===ve(e.m.e)||e.m.e===Ie)&&`is-on`),style:{left:e.x,top:e.y},"aria-hidden":`true`,onPointerEnter:ye?()=>Te(ve(e.m.e)):void 0,onPointerLeave:ye?()=>Te(null):void 0,children:e.n},`n`+e.m.idx));return{paths:e,labels:t,hitPaths:b,need:n,crowd:r,wide:f,least:p,covered:i,numbered:U}};for(let e in ot){let t=V[e]-1;t>=0&&(R[t]=Math.max(R[t],ot[e]*28+40))}let ct=R.slice();W();let lt=st(),ut=()=>[...lt.need].filter(e=>R[e]<ct[e]+144);for(let e=0;e<6&&ut().length;e++){for(let e of ut())R[e]=Math.min(ct[e]+144,R[e]+24);W(),lt=st()}let dt=[...lt.need].filter(e=>R[e]>=ct[e]+144);if(dt.length){for(let e of dt)R[e]=ct[e];W(),lt=st();let e=()=>[...lt.crowd].filter(e=>dt.includes(e)&&R[e]<ct[e]+144);for(let t=0;t<6&&e().length;t++){for(let t of e())R[t]=Math.min(ct[t]+144,R[t]+24);W(),lt=st()}}for(let e=0;e<3&&lt.least<0;e++){let e=Math.ceil(-lt.least);for(let t in B)B[t].x+=e;P+=e,lt=st()}lt.wide>P&&(P=Math.ceil(lt.wide),lt=st());let{paths:ft,labels:pt,hitPaths:mt,numbered:ht}=lt,gt=Math.min(...x.filter(e=>B[e.id]).map(e=>ne(e.id).x),P),_t=_!=null&&B[_]?ne(_):null,vt=t=>gx(e.sizeLabel,t,()=>_x(t,`1 個項目`,`{n} 個項目`)),yt=e.externalLabel??w(`repo 外`),bt=e.useLabel??w(`使用 {n} 次`),xt=e=>e.tag?/* @__PURE__ */ (0,A.jsxs)(`span`,{className:M(`ui-lg-tag`,e.tagTone===`warning`&&`is-warning`),children:[e.tagTone===`warning`?/* @__PURE__ */ (0,A.jsx)(Y,{name:`lock`,size:12}):null,e.tag]}):null,St=x.map(t=>{let n=B[t.id],r=t.id===_,i=v(t),a=Be?ze[Be]?.[t.id]:void 0;return/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-lg-node`,t.external&&`is-external`,r&&`is-selected`,!Ue(t.id)&&`is-dim`),onFocus:vx,style:{left:ne(t.id).x,top:n.y,width:ne(t.id).w,height:C},"aria-pressed":e.onSelect?r:void 0,onClick:e.onSelect?()=>We(t.id,r):void 0,children:[/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-lg-head`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-lg-name`,t.code&&`is-code`),children:t.name||t.id}),S?null:xt(t),a?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-lg-use`,children:F(bt.replace(`{n}`,``),[a])}):null]}),S?xt(t):null,t.external?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-lg-ext`,children:yt}):null,i==null?null:/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-lg-size`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-lg-track`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(`span`,{style:{width:Math.round(i/re*100)+`%`}})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-lg-count`,children:F(vt(i),[p_.number(i)])})]})]},t.id)}),Ct=e.sharedMeta??w(`{a} 個項目使用,共 {b} 次`),wt=T.map(t=>{let n=ze[t.id]??{},r=Object.values(n).reduce((e,t)=>e+t,0),i=t.id===_,a=!!Ie||_!=null&&!i&&(Be==null?!(_ in n):!(t.id in(ze[Be]??{}))&&!(Be in n));return/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-lg-node`,`ui-lg-chip`,i&&`is-selected`,a&&`is-dim`),onFocus:vx,"aria-pressed":e.onSelect?i:void 0,onClick:e.onSelect?()=>We(t.id,i):void 0,children:[/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-lg-head`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-lg-name`,t.code&&`is-code`),children:t.name||t.id}),xt(t)]}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-lg-shared-meta`,children:F(Ct.replace(`{a}`,``).replace(`{b}`,``),[Object.keys(n).length,r])})]},t.id)}),Tt=e=>D(e)?e.label?w(`{label}({inferred})`,{label:e.label,inferred:Ye(e)}):Ye(e):Ke(e),Et=(e,t,n,r,i,a)=>/* @__PURE__ */ (0,A.jsxs)(`li`,{className:M(`ui-lg-li`,n&&`is-dim`),children:[r?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:M(`ui-lg-libtn`,t&&`is-selected`),"aria-pressed":t,onClick:r,children:i}):/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-lg-lihead`,children:i}),a]},e),Dt=new Set(g.map(e=>e.id)),Ot=/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-lg-list`,children:[/* @__PURE__ */ (0,A.jsxs)(`section`,{"aria-labelledby":`${je}-ln`,children:[/* @__PURE__ */ (0,A.jsx)(`h3`,{id:`${je}-ln`,className:`ui-lg-listtitle`,children:e.listLabels?.nodes??w(`項目`)}),/* @__PURE__ */ (0,A.jsx)(`ul`,{children:g.map(t=>{let n=v(t);return Et(t.id,t.id===_,!Ue(t.id),e.onSelect?()=>We(t.id,t.id===_):void 0,/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-lg-liname`,t.code&&`ui-lg-code`),children:t.name||t.id}),xt(t)]}),t.external&&!t.shared?/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-lg-limeta`,children:[w(`,`),yt]}):n==null?null:/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-lg-limeta`,children:[w(`,`),F(vt(n),[p_.number(n)])]}))})})]}),/* @__PURE__ */ (0,A.jsxs)(`section`,{"aria-labelledby":`${je}-le`,children:[/* @__PURE__ */ (0,A.jsx)(`h3`,{id:`${je}-le`,className:`ui-lg-listtitle`,children:e.listLabels?.edges??w(`關係`)}),/* @__PURE__ */ (0,A.jsx)(`ul`,{children:e.edges.filter(e=>Dt.has(e.from)&&Dt.has(e.to)).map((e,t)=>Et(ve(e)+`:`+t,e===Le,He&&!Ve(e)&&!(Be&&e.to===Be),ye?()=>rt(e):void 0,/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-lg-code`,children:Ge(e.from)}),` `,/* @__PURE__ */ (0,A.jsx)(`span`,{"aria-hidden":`true`,children:`→`}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:w(`到`)}),` `,/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-lg-code`,children:Ge(e.to)}),/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-lg-limeta`,children:[w(`:`),Ex(Tt(e))]})]}),null))})]})]}),kt=e.listView!==!1&&Me===`list`,At=y.useRef(``);y.useLayoutEffect(()=>{let e=Ee.current;if(!e||kt||!a?.full||At.current===Pe||(At.current=Pe,fx.get(Pe)))return;let t=_t?_t.x+_t.w/2-e.clientWidth/(2*h):gt-16;e.scrollLeft=Math.max(0,t*h)});let jt=_t?.x,Mt=_t?.w;y.useEffect(()=>{let e=Ee.current;if(!e||kt||jt==null||Mt==null)return;let t=jt*h,n=(jt+Mt)*h;t<e.scrollLeft?e.scrollLeft=Math.max(0,t-16):n>e.scrollLeft+e.clientWidth&&(e.scrollLeft=n-e.clientWidth+16)},[_,jt,Mt,h,kt,Ee]);let Nt=e.labelToggle!==!1&&!kt&&e.edges.some(e=>D(e));y.useLayoutEffect(()=>{let e=Ee.current;if(!e)return;let t=()=>n(e.clientWidth);t();let r=U(t);return r?.observe(e),()=>r?.disconnect()},[Ee,kt]),y.useLayoutEffect(()=>{if(!t||kt)return;if(!a){if(P<=t+.5)return;let n=e.nodeWidth||200,r=P-t-(N-1)*16,a=Math.max(Math.min(n,120),Math.floor(n-Math.max(0,r)/N));i({at:t,nw:a,col:24,scale:1});return}if(a.full)return;let n=Math.floor(t/P*1e3)/1e3;if(P>t+.5&&n<.75){i({...a,nw:e.nodeWidth||200,col:40,scale:1,full:!0});return}let r=P<=t+.5?1:n;r!==a.scale&&i({...a,scale:r})},[t,kt,a,P,e.nodeWidth,N]);let Pt=lt.covered;y.useLayoutEffect(()=>{Pt&&p<5&&f({key:u,n:p+1})},[Pt,p,u]);let Ft=z*h,It=Ft-Math.max(0,s),Lt=e.resizable&&s<0?Math.max(Math.min(160,It),It+s):null,Rt=e=>Math.max(Math.min(160,It)-It,Math.min(e,I?200*I*h:0));return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-graph ui-lg`,e.className),children:[e.listView===!1&&!Nt&&!e.toolbar?null:/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-lg-bar`,children:[e.toolbar?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-lg-toolbar`,children:e.toolbar}):null,Nt&&e.labelToggle===`icon`?/* @__PURE__ */ (0,A.jsx)(np,{className:`ui-lg-labels-btn`,icon:`tag`,filled:be,label:w(`顯示線上文字`),"aria-pressed":be,onClick:Ce}):Nt?/* @__PURE__ */ (0,A.jsxs)(`label`,{className:`ui-lg-labels-switch`,children:[/* @__PURE__ */ (0,A.jsx)(dx,{checked:be,onChange:Ce,label:w(`線上文字`)}),/* @__PURE__ */ (0,A.jsx)(`span`,{"aria-hidden":`true`,children:w(`線上文字`)})]}):null,e.listView===!1?null:/* @__PURE__ */ (0,A.jsx)(ay,{label:w(`顯示方式`),value:Me,onChange:Ne,items:[{id:`graph`,label:w(`圖`)},{id:`list`,label:w(`清單`)}]})]}),kt?Ot:null,/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-lg-scroller`,De&&`has-more`,kt&&`is-hidden`),children:/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-lg-scroll`,Lt!=null&&`is-framed`),ref:Ee,onScroll:Fe,style:Lt==null?void 0:{height:Lt},children:/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-lg-canvas`,style:h===1?{width:P,height:z}:{width:P,height:z,transform:`scale(${h})`,transformOrigin:`0 0`,marginRight:P*(h-1),marginBottom:z*(h-1),"--lg-scale":h},role:`group`,"aria-label":e.label||w(`架構圖`),onClick:ye&&e.selectedEdge!=null?()=>ye(null):void 0,children:[/* @__PURE__ */ (0,A.jsx)(`svg`,{width:P,height:z,viewBox:`0 0 ${P} ${z}`,"aria-hidden":`true`,children:ft}),St,pt,mt.length&&!ye?/* @__PURE__ */ (0,A.jsx)(`svg`,{className:`ui-lg-hits`,width:P,height:z,viewBox:`0 0 ${P} ${z}`,"aria-hidden":`true`,children:mt}):mt.length?/* @__PURE__ */ (0,A.jsx)(`svg`,{className:`ui-lg-hits`,width:P,height:z,viewBox:`0 0 ${P} ${z}`,role:`group`,"aria-label":w(`關係`),children:mt}):null]})})}),e.resizable&&!kt?/* @__PURE__ */ (0,A.jsx)(xx,{value:Math.round(Ft+Math.min(0,s)),min:Math.round(Math.min(160,Ft)),max:Math.round(Ft-Math.max(0,s)+200*I*h),onDrag:e=>l(Rt(e)),onKey:e=>l(Rt(s+e)),onReset:()=>l(0),start:()=>s}):null,kt?null:/* @__PURE__ */ (0,A.jsx)(sy,{show:Oe,done:ke}),kt||!ht.length?null:/* @__PURE__ */ (0,A.jsx)(`ol`,{className:`ui-lg-numlist`,"aria-label":w(`編號的線`),children:ht.map(e=>/* @__PURE__ */ (0,A.jsxs)(`li`,{className:M(e.m.dim&&`is-dim`),children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-lg-num is-static`,"aria-hidden":`true`,children:e.n}),/* @__PURE__ */ (0,A.jsx)(`span`,{children:Ex(e.m.text)})]},e.n))}),T.length&&!kt?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-lg-shared`,children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-lg-shared-title`,children:e.sharedLabel||w(`共用項目`)}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-lg-chips`,children:wt})]}):null,kt||e.legend===!1||!e.legendItems&&!E.some(e=>B[e.from]&&B[e.to])?null:/* @__PURE__ */ (0,A.jsx)(yb,{items:e.legendItems||[...E.some(e=>!D(e)&&B[e.from]&&B[e.to])?[{type:`weight`,label:`次數越多線越粗`}]:[],...E.some(e=>e.inferred&&!e.declared&&B[e.from]&&B[e.to])?[{type:`inferred`,label:e.inferredLabel||`推測的關係`,text:e.inferredText}]:[],...E.some(e=>e.declared&&B[e.from]&&B[e.to])?[{type:`declared`,label:e.declaredLegend||`專案宣告的關係`,text:e.declaredText}]:[]]})]})}function Ax({segments:e,classes:t,label:n,count:r,times:i,legend:a=!0,className:o}){let s=e=>S_(Math.max(0,t.findIndex(t=>t.value===e))),c=e=>t.find(t=>t.value===e)?.label??e,l=e.map(e=>(i?i[e.from]+` `+w(`到`)+` `+(i[e.to]??i[i.length-1])+` `:``)+c(e.value)).join(w(`,`));return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-statusband`,o),children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-statusband-bar`,role:`img`,"aria-label":n+w(`:`)+(l||w(`沒有資料`)),children:e.map((e,t)=>/* @__PURE__ */ (0,A.jsx)(`span`,{style:{left:e.from/r*100+`%`,width:(Math.min(r,e.to)-e.from)/r*100+`%`,background:s(e.value)}},t))}),a?/* @__PURE__ */ (0,A.jsx)(jx,{classes:t,label:n}):null]})}function jx({classes:e,label:t}){return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-chart-legend ui-statusband-legend`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{children:t}),e.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`span`,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-chart-swatch`,style:{background:S_(t)}}),e.label]},e.value))]})}function Mx(e,t,n){let r=[],i=[];return e.forEach((e,a)=>{e==null||Number.isNaN(e)?(i.length&&r.push(i),i=[]):i.push([t(a),n(e)])}),i.length&&r.push(i),r}let Nx=(e,t)=>e?.color?S_(e.color-1):S_(t);function Px({series:e,labels:t,label:n,unit:r,decimals:i,max:a,min:o=0,labelEvery:s=1,band:c,now:l,thresholds:u,marker:d,playhead:f,onPlayheadChange:p,headline:m,status:h,empty:g,height:_=240,className:v}){let[b,x]=y.useState(-1),S=y.useRef(null),[C,T]=y.useState(640);y.useLayoutEffect(()=>{let e=S.current;if(!e)return;let t=()=>{e.clientWidth>0&&T(e.clientWidth)};if(t(),typeof ResizeObserver!=`function`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let E=C-10,D=_-30,O=`ui-stripes-`+y.useId().replace(/:/g,``),k=y.useRef(!1),j=e.flatMap(e=>e.values.filter(e=>e!=null)),N=a??D_(Math.max(o+1,...j,...(u??[]).map(e=>e.value))-o)+o,P=t.length||e[0]?.values.length||0,F=(E-40)/Math.max(1,P-1),I=e=>40+e*F,L=e=>D-(e-o)/(N-o)*(D-10),R=C_.map(e=>o+e*(N-o)),z=r?` `+r:``,B=e=>e==null?`—`:p_.number(e,i)+z,V=f!=null&&!!p,H=n=>{x(n),bi(t[n]+w(`:`)+e.filter(e=>e.values[n]!=null).map(t=>(e.length>1?t.name+` `:``)+B(t.values[n])).join(w(`,`)))},U=e=>{V&&p(e),H(e)},ee=e=>{let t=e.currentTarget.getBoundingClientRect(),n=(e.clientX-t.left)/t.width*C;return Math.max(0,Math.min(P-1,Math.round((n-40)/F)))},te={left:(40-F/2)/C*100+`%`,right:(C-E-F/2)/C*100+`%`},W=e.length>1||c,re=Math.max(0,...t.map(e=>e.length))*7.5+12,ie=Math.max(s,Math.ceil(P*re/Math.max(1,E-40)/s)*s),G=d?I(d.at)+10+[...d.label].reduce((e,t)=>e+(t.charCodeAt(0)>11904?14:8),0)>C:!1,K=[];if(c){let t=e[c.between[0]]?.values??[],n=e[c.between[1]]?.values??[];for(let e=0;e<P-1;e++){let r=t[e],i=t[e+1],a=n[e],o=n[e+1];r!=null&&i!=null&&a!=null&&o!=null&&K.push({d:`M${I(e)},${L(r)} L${I(e+1)},${L(i)} L${I(e+1)},${L(o)} L${I(e)},${L(a)} Z`,up:r+i>=a+o})}}let q=t=>{let n=e.map((n,r)=>({color:Nx(e[r],r),name:n.name,value:n.values[t]})).filter(e=>e.value!=null).map(e=>({...e,value:B(e.value)}));if(c){let r=e[c.between[0]]?.values[t],i=e[c.between[1]]?.values[t];r!=null&&i!=null&&n.push({color:``,name:w(`差`),value:(r-i>0?`+`:``)+B(r-i)})}return n},ae=b>=0?b:-1;return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-chart`,v),children:[m?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-chart-headline`,children:m}):null,W?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-chart-legend`,children:[e.map((t,n)=>/* @__PURE__ */ (0,A.jsxs)(`span`,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-chart-swatch`,t.dashed&&`is-dashed`),style:{background:t.dashed?void 0:Nx(e[n],n),color:Nx(e[n],n)}}),t.name]},n)),c?/* @__PURE__ */ (0,A.jsxs)(`span`,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-chart-swatch`,`is-band`,`is-`+c.tone)}),c.label]}):null]}):null,/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:S,className:M(`ui-chart-plot`,V&&`is-replay`),tabIndex:P?0:void 0,role:`group`,"aria-label":n,"aria-description":w(V?`左右方向鍵移動播放頭`:`左右方向鍵查看每一個時間點的數值`),onMouseLeave:()=>!k.current&&x(-1),onFocus:()=>b<0&&P&&H(V?f:0),onBlur:()=>x(-1),onKeyDown:e=>{let t=O_(e,V?f:b,P);t!=null&&U(t)},onPointerDown:V?e=>{if(e.button===0){k.current=!0;try{e.currentTarget.setPointerCapture?.(e.pointerId)}catch{}U(ee(e))}}:void 0,onPointerMove:V?e=>{k.current&&U(ee(e))}:void 0,onPointerUp:()=>{k.current=!1},onPointerCancel:()=>{k.current=!1},children:[/* @__PURE__ */ (0,A.jsxs)(`svg`,{viewBox:`0 0 ${C} ${_}`,width:`100%`,height:_,"aria-hidden":`true`,children:[l!=null&&l<P-1?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`defs`,{children:/* @__PURE__ */ (0,A.jsx)(`pattern`,{id:O,width:`9`,height:`9`,patternUnits:`userSpaceOnUse`,patternTransform:`rotate(45)`,children:/* @__PURE__ */ (0,A.jsx)(`rect`,{width:`4`,height:`9`,className:`ui-chart-stripe`})})}),/* @__PURE__ */ (0,A.jsx)(`rect`,{x:I(l),y:10,width:E-I(l),height:D-10,fill:`url(#${O})`})]}):null,R.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`g`,{children:[/* @__PURE__ */ (0,A.jsx)(`line`,{x1:40,x2:E,y1:L(e),y2:L(e),className:t?`ui-chart-grid`:`ui-chart-axis`}),/* @__PURE__ */ (0,A.jsx)(`text`,{x:32,y:L(e)+4,textAnchor:`end`,className:`ui-chart-tick`,children:p_.number(e,y_(N-o))})]},t)),K.map((e,t)=>/* @__PURE__ */ (0,A.jsx)(`path`,{d:e.d,className:M(`ui-chart-band`,c?.tone===`success`?`is-success`:e.up?`is-pos`:`is-neg`)},t)),(u??[]).map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`g`,{className:`ui-chart-threshold is-`+e.tone,children:[/* @__PURE__ */ (0,A.jsx)(`line`,{x1:40,x2:E,y1:L(e.value),y2:L(e.value)}),/* @__PURE__ */ (0,A.jsx)(`text`,{x:E-2,y:L(e.value)-5,textAnchor:`end`,children:e.label})]},t)),e.map((t,n)=>Mx(t.values,I,L).map((r,i)=>/* @__PURE__ */ (0,A.jsx)(`path`,{d:b_(r),pathLength:t.dashed?void 0:1,className:M(`ui-chart-line`,t.dashed&&`is-dashed`),style:{stroke:Nx(e[n],n),animationDelay:n*150+`ms`}},n+`-`+i))),l==null?null:/* @__PURE__ */ (0,A.jsxs)(`g`,{className:`ui-chart-now`,children:[/* @__PURE__ */ (0,A.jsx)(`line`,{x1:I(l),x2:I(l),y1:6,y2:D}),/* @__PURE__ */ (0,A.jsx)(`text`,{x:I(l),y:2,textAnchor:`middle`,children:w(`現在`)})]}),d?/* @__PURE__ */ (0,A.jsxs)(`g`,{className:`ui-chart-marker`,children:[/* @__PURE__ */ (0,A.jsx)(`circle`,{cx:I(d.at),cy:L(d.value),r:5.5,style:{stroke:Nx(e[d.series??e.length-1],d.series??e.length-1)}}),/* @__PURE__ */ (0,A.jsx)(`text`,{x:I(d.at)+(G?-10:10),y:L(d.value)+20,textAnchor:G?`end`:`start`,children:d.label})]}):null,V?/* @__PURE__ */ (0,A.jsxs)(`g`,{className:`ui-chart-playhead`,children:[/* @__PURE__ */ (0,A.jsx)(`line`,{x1:I(f),x2:I(f),y1:10,y2:D}),/* @__PURE__ */ (0,A.jsx)(`circle`,{cx:I(f),cy:D,r:8})]}):null]}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-chart-hit`,style:{...te,bottom:30},children:t.map((t,n)=>/* @__PURE__ */ (0,A.jsx)(`div`,{onMouseEnter:()=>!k.current&&x(n),className:`ui-chart-col`,children:ae===n?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-chart-guide`}),e.map((t,r)=>{let i=t.values[n];return i==null?null:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-chart-dot`,style:{top:L(i)/D*100+`%`,background:Nx(e[r],r)}},r)})]}):null},n))}),j.length?null:/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-chart-empty`,children:g??w(`這段時間沒有資料`)}),ae>=0?/* @__PURE__ */ (0,A.jsx)(E_,{title:t[ae],style:{left:I(ae)/C*100+`%`,transform:ae>P*.65?`translateX(calc(-100% - 12px))`:`translateX(12px)`},rows:q(ae)}):null]}),h?/* @__PURE__ */ (0,A.jsx)(`div`,{style:{marginLeft:te.left,marginRight:te.right},children:/* @__PURE__ */ (0,A.jsx)(Ax,{...h,count:P,times:t,legend:!1,className:`is-attached`})}):null,/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-chart-xlabels`,style:{marginLeft:te.left,marginRight:te.right},children:t.map((e,t)=>/* @__PURE__ */ (0,A.jsx)(`span`,{children:ie>1&&t%ie?``:ne(e)},t))}),h?/* @__PURE__ */ (0,A.jsx)(jx,{classes:h.classes,label:h.label}):null]})}function Fx({label:e,value:t,min:n,max:r,warn:i,limit:a,unit:o,decimals:s=0,className:c}){let l=r-n||1,u=e=>Math.max(0,Math.min(100,(e-n)/l*100)),d=a!=null&&t>=a?`danger`:i!=null&&t>=i?`warning`:`success`,f=w(d===`danger`?`⚠ 超過上限`:d===`warning`?`⚠ 注意`:`正常`),p=e=>p_.number(e,s)+(o?` `+o:``),m=e=>p_.number(e,(String(e).split(`.`)[1]??``).length),h=y.useRef(null),[g,_]=y.useState(!1),v=i==null?null:u(i),b=a==null?null:u(a),x=[[`var(--meter-ok)`,0,v??b??100],...v==null?[]:[[`var(--meter-warn)`,v,b??100]],...b==null?[]:[[`var(--meter-over)`,b,100]]],S=[...i==null?[]:[{v:i,at:v,tone:`warning`,text:w(`注意 {v}`,{v:m(i)})}],...a==null?[]:[{v:a,at:b,tone:`danger`,text:w(`上限 {v}`,{v:m(a)})}]];return y.useLayoutEffect(()=>{let e=h.current;if(!e)return;let t=()=>{let[t,n]=[...e.children].map(e=>e.getBoundingClientRect());_(!!t&&!!n&&t.right+8>n.left&&t.left<n.right+8)};t();let n=typeof ResizeObserver==`function`?new ResizeObserver(t):null;return n?.observe(e),()=>n?.disconnect()},[i,a,n,r]),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-meter`,c),role:`meter`,"aria-label":e,"aria-valuenow":t,"aria-valuemin":n,"aria-valuemax":r,"aria-valuetext":p(t)+w(`,`)+f.replace(`⚠ `,``)+S.map(e=>w(`,`)+e.text).join(``),children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-meter-head`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-meter-label`,children:e}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-meter-state is-`+d,children:f}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-meter-value`,children:p(t)})]}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-meter-track`,"aria-hidden":`true`,style:{background:`linear-gradient(90deg, ${x.map(([e,t,n])=>`${e} ${t}% ${n}%`).join(`, `)})`},children:[S.map(e=>/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-meter-mark is-`+e.tone,style:{left:e.at+`%`}},e.tone)),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-meter-dot is-`+d,style:{left:u(t)+`%`}})]}),S.length?/* @__PURE__ */ (0,A.jsx)(`div`,{ref:h,className:M(`ui-meter-marks`,g&&`is-stacked`),"aria-hidden":`true`,children:S.map(e=>/* @__PURE__ */ (0,A.jsx)(`span`,{className:`is-`+e.tone,style:e.tone===`warning`&&S.length>1?{right:100-e.at+`%`}:e.at>80?{right:0}:{left:e.at+`%`},children:e.text},e.tone))}):null]})}let Ix=/^(heat-[1-7]|diverge-(neg|pos)(-strong)?|diverge-zero|chart-[1-4])$/;function Lx({zones:e,label:t,columns:n=4,rowHeight:r=120,fill:i=!1,min:a=20,max:o=30,selectedId:s,onSelect:c,className:l}){return/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-zonemap`,i&&`is-fill`,l),role:`group`,"aria-label":t,style:{"--zone-cols":n,gridAutoRows:i?`minmax(${r}px, 1fr)`:r+`px`},children:e.map(e=>{let t=e.area?{gridRow:`${e.area.row} / span ${e.area.rows??1}`,gridColumn:`${e.area.col} / span ${e.area.cols??1}`}:void 0;if(e.value==null&&!e.forecast)return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-zone is-empty`,style:t,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-zone-name`,children:e.name}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-zone-detail`,children:w(`沒有資料`)})]},e.id);let n=e.tone??`normal`,r=e.fill??(e.value==null?`surface-sub`:Rm(e.value,a,o)),i=/^[a-z][a-z0-9-]*$/.test(r)?`var(--${r})`:r,l=(n===`normal`?``:`⚠ `)+(e.state??(e.forecast?w(`預測`):w(`正常`))),u=e.value==null?`—`:p_.number(e.value,e.decimals??1),d=s===e.id;return/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-zone`,`is-`+n,e.forecast&&`ui-forecast`,d&&`is-selected`),"data-fill":r,style:{...t,background:i,color:Ix.test(r)?void 0:Lm(r)},"aria-pressed":d,"aria-label":[e.name,u+(e.unit?` `+e.unit:``),l.replace(`⚠ `,``),e.detail].filter(Boolean).join(w(`,`)),onClick:()=>c?.(e),children:[/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-zone-head`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-zone-name`,children:e.name}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-zone-state`,children:l})]}),/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-zone-value`,children:[u,e.unit?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-zone-unit`,children:e.unit}):null]}),e.detail?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-zone-detail`,children:e.detail}):null]},e.id)})})}Rr(),Br(),Xn(),er(),ti(Lr,zr,Yn,$n);let Rx={alert:{icon:`warning`,name:`告警`},switch:{icon:`arrows-left-right`,name:`切換`},ai:{icon:`sparkle`,name:`AI`},manual:{icon:`user`,name:`人工`}};function zx({events:e,label:t,empty:n,className:r}){let i=[...e].sort((e,t)=>t.time.getTime()-e.time.getTime());return i.length?/* @__PURE__ */ (0,A.jsx)(`ol`,{className:M(`ui-events`,r),"aria-label":t,children:i.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`li`,{className:`is-`+e.kind,children:[/* @__PURE__ */ (0,A.jsx)(`time`,{className:`ui-events-time`,dateTime:e.time.toISOString(),children:p_.time(e.time)}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-events-kind`,role:`img`,"aria-label":w(Rx[e.kind].name),children:/* @__PURE__ */ (0,A.jsx)(Y,{name:Rx[e.kind].icon,size:20})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-events-text`,children:im(e.text)})]},e.id??t))}):/* @__PURE__ */ (0,A.jsx)(`p`,{className:M(`ui-events-empty`,r),children:n??w(`沒有事件`)})}Wr(),Te(),ti(Ur,we);function Bx(e,t){return Math.max(1,Math.min(1.5,Math.min(e/1440,t/900)))}function Vx({title:e,tags:t,status:n,kpis:r,clock:i,fullscreen:a=!0,main:o,side:s,bottom:c,extras:l,className:u}){let d=y.useRef(null),[f,p]=y.useState(null),[m,h]=y.useState(!1),g=typeof document<`u`&&document.fullscreenEnabled===!0;y.useLayoutEffect(()=>{let e=d.current;if(!e)return;let t=()=>p({w:e.clientWidth,h:e.clientHeight});if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),y.useEffect(()=>{let e=()=>h(document.fullscreenElement!=null&&document.fullscreenElement===d.current);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let _=()=>{let e=d.current;e&&(document.fullscreenElement?document.exitFullscreen().catch(()=>void 0):e.requestFullscreen().catch(()=>void 0))},v=f!=null&&f.w<600,b=f&&!v?Bx(f.w,f.h):1,x=f?f.h/b:0,S=(l??[]).filter(e=>v||x>=e.minHeight),C=f&&!v&&b!==1?{zoom:b,width:f.w/b,height:f.h/b}:void 0,T=/* @__PURE__ */ (0,A.jsxs)(`header`,{className:`ui-console-top`,children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-console-start`,children:[/* @__PURE__ */ (0,A.jsx)(`h1`,{className:`ui-console-title`,children:e}),t]}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-console-end`,children:[n==null?null:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-console-status`,children:n}),r==null?null:/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-console-kpis`,children:r}),i==null?null:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-console-clock`,children:i}),a&&g&&!v?/* @__PURE__ */ (0,A.jsx)(np,{label:w(m?`離開全螢幕`:`全螢幕`),icon:m?`corners-in`:`corners-out`,onClick:_}):null]})]});return/* @__PURE__ */ (0,A.jsx)(`div`,{ref:d,className:M(`ui-console`,v&&`is-stacked`,u),children:/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-console-frame`,style:C,children:[T,/* @__PURE__ */ (0,A.jsx)(`main`,{className:`ui-console-main`,children:o}),v?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[s,c,S.map(e=>/* @__PURE__ */ (0,A.jsx)(y.Fragment,{children:e.node},e.id))]}):/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsxs)(`aside`,{className:`ui-console-side`,"aria-label":w(`側欄`),children:[s,S.map(e=>/* @__PURE__ */ (0,A.jsx)(y.Fragment,{children:e.node},e.id))]}),c==null?null:/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-console-bottom`,children:c})]})]})})}function Hx({time:e,replaying:t,onReplayChange:n,onNow:r,status:i,detail:a,className:o}){return/* @__PURE__ */ (0,A.jsxs)(`section`,{className:M(`ui-timecontrol`,o),"aria-label":w(`時間控制`),children:[/* @__PURE__ */ (0,A.jsx)(`time`,{className:`ui-timecontrol-clock`,dateTime:e.toISOString(),"aria-live":`off`,children:p_.time(e)}),/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-timecontrol-status`,"aria-live":`polite`,children:i}),a?/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-timecontrol-detail`,children:a}):null,/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-timecontrol-actions`,children:[/* @__PURE__ */ (0,A.jsx)(Xp,{onClick:()=>n(!t),children:w(t?`停止回放`:`回放`)}),/* @__PURE__ */ (0,A.jsx)(Xp,{onClick:r,disabled:!t,children:w(`回到現在`)})]})]})}function Ux({label:e,className:t}){return/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-loading`,t),role:`progressbar`,"aria-label":e||w(`載入中`),"aria-busy":`true`,children:/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-loading-drop`})})}function Wx({label:e,hint:t,error:n,id:r,className:i,required:a,disabled:o,...s}){let c=y.useId(),l=r||c,u=n?l+`-err`:t?l+`-hint`:void 0;return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-field`,n&&`has-error`,o&&`is-disabled`,i),children:[/* @__PURE__ */ (0,A.jsx)(N_,{htmlFor:l,required:a,children:e}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-field-box`,children:[/* @__PURE__ */ (0,A.jsx)(`input`,{type:`text`,...s,required:a,disabled:o,id:l,className:`ui-input`,"aria-invalid":n?!0:void 0,"aria-describedby":u}),n?/* @__PURE__ */ (0,A.jsx)(F_,{}):null]}),u?/* @__PURE__ */ (0,A.jsx)(I_,{id:u,error:n,hint:t}):null]})}_t(),yt(),ti(gt,vt);function Gx(e){let t=y.useId(),[n,r]=y.useState(``),[i,a]=y.useState(``),[o,s]=y.useState(!1),[c,l]=y.useState(!1),u=e.error||{},d=c&&!n?w(`請輸入帳號`):u.account,f=c&&!i?w(`請輸入密碼`):u.password;function p(t){t.preventDefault(),l(!0),n&&i&&e.onSubmit({account:n,password:i})}return/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-loginpage`,e.className),children:/* @__PURE__ */ (0,A.jsxs)(`form`,{className:`ui-logincard`,onSubmit:p,noValidate:!0,children:[e.brand?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-login-brand`,children:e.brand}):null,/* @__PURE__ */ (0,A.jsx)(`h1`,{className:`ui-login-title`,children:e.title||w(`登入`)}),/* @__PURE__ */ (0,A.jsx)(Wx,{label:w(`帳號`),value:n,onChange:e=>r(e.target.value),placeholder:w(`Email 或帳號`),autoComplete:`username`,error:d}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-field`,f&&`has-error`),children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-login-pwlabel`,children:[/* @__PURE__ */ (0,A.jsx)(N_,{htmlFor:t,children:w(`密碼`)}),e.forgotHref?/* @__PURE__ */ (0,A.jsx)(`a`,{href:e.forgotHref,className:`ui-link`,children:w(`忘記密碼`)}):null]}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-pwfield`,f&&`is-invalid`),children:[/* @__PURE__ */ (0,A.jsx)(`input`,{id:t,className:`ui-pwfield-input`,type:o?`text`:`password`,value:i,autoComplete:`current-password`,"aria-invalid":f?!0:void 0,"aria-describedby":f?t+`-err`:void 0,onChange:e=>a(e.target.value)}),f?/* @__PURE__ */ (0,A.jsx)(F_,{inline:!0}):null,/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-datefield-btn`,"aria-label":w(o?`隱藏密碼`:`顯示密碼`),"aria-pressed":o,onClick:()=>s(!o),children:/* @__PURE__ */ (0,A.jsx)(Y,{name:o?`eye-slash`:`eye`,size:18})})]}),/* @__PURE__ */ (0,A.jsx)(I_,{id:t+`-err`,error:f})]}),/* @__PURE__ */ (0,A.jsx)(Xp,{variant:`primary`,type:`submit`,loading:e.loading,className:`ui-login-submit`,children:w(`登入`)})]})})}function Kx(e){let t=y.useRef(!0);t.current&&(t.current=!1,e())}function qx(e,t,n,r,i,a,o,s,c,l=2){let u=Fs(n.current,{event:e,orientation:r,loopFocus:i,rtl:a,cols:l,disabledIndices:o,minIndex:s,maxIndex:c,prevIndex:t>c?s:t,stopEvent:!0});return As(n.current,u)?void 0:u}let Jx=/*#__PURE__*/ y.createContext(void 0),Yx=/*#__PURE__*/ y.createContext(void 0),Xx=/*#__PURE__*/ y.createContext(void 0),Zx=/*#__PURE__*/ y.createContext(!1),Qx=/*#__PURE__*/ y.createContext(``);function $x(){let e=y.useContext(Jx);if(!e)throw Error(Pi(22));return e}function eS(){let e=y.useContext(Yx);if(!e)throw Error(Pi(23));return e}function tS(){let e=y.useContext(Xx);if(!e)throw Error(Pi(24));return e}function nS(){return y.useContext(Qx)}function rS(){return y.useContext(Zx)}function iS(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}let aS=(e,t)=>Object.is(e,t);function oS(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function sS(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!iS(e,t,(e,t)=>oS(e,t,n)):e!==t}function cS(e,t,n){return e?e.some(e=>e!==void 0&&oS(t,e,n)):!1}function lS(e,t,n){return e?e.findIndex(e=>e!==void 0&&oS(e,t,n)):-1}function uS(e,t){if(t!==aS)return n=>cS(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function dS(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(uS(t,n)):lS(e,t,n);return i===-1?null:i}function fS(e,t,n,r,i,a){return cS(r,t,i)?a!=null&&e>a&&cS(r,n[a],i)?a:e:e===a?dS(n,r,i,!0):a}function pS(e,t,n){return e.filter(e=>!oS(t,e,n))}let mS={id:e=>e.id,labelId:e=>e.labelId,items:e=>e.items,selectedValue:e=>e.selectedValue,hasSelectionChips:e=>{let t=e.selectedValue;return Array.isArray(t)&&t.length>0},hasSelectedValue:e=>{let{selectedValue:t,selectionMode:n}=e;return t==null?!1:n===`multiple`&&Array.isArray(t)?t.length>0:!0},hasNullItemLabel:(e,t)=>t?Fg(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMounted:e=>e.forceMounted,inline:e=>e.inline,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(e=>oS(t,e,n)):oS(t,r,n)},transitionStatus:e=>e.transitionStatus,popupProps:e=>e.popupProps,listProps:e=>e.listProps,inputProps:e=>e.inputProps,triggerProps:e=>e.triggerProps,itemRoot:e=>e.itemRoot,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupId:e=>e.popupId,triggerElement:e=>e.triggerElement,inputElement:e=>e.inputElement,inputGroupElement:e=>e.inputGroupElement,popupSide:e=>e.popupSide,openMethod:e=>e.openMethod,inputInsidePopup:e=>e.inputInsidePopup,inputOwnsFormValue:e=>e.inputOwnsFormValue,selectionMode:e=>e.selectionMode,name:e=>e.name,form:e=>e.form,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,grid:e=>e.grid,virtualized:e=>e.virtualized,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,modal:e=>e.modal,autoHighlight:e=>e.autoHighlight},hS={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},gS={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},_S={disabled:!1,...gS},vS={valid(e){return e===null?null:e?{"data-valid":``}:{"data-invalid":``}}},yS={invalid:void 0,name:void 0,validityData:{state:hS,errors:[],error:``,value:``,initialValue:null},setValidityData:Ai,disabled:void 0,setTouched:Ai,setDirty:Ai,setFilled:Ai,setFocused:Ai,focusOwnerRef:{current:void 0},validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:_S,registerFieldControl:Ai,validation:{getValidationProps:(e,t=Mi)=>t,inputRef:{current:null},registeredInputs:/* @__PURE__ */ new Map,registerInput:Ai,getInputControl:()=>null,commit:async()=>{},change:Ai}},bS=/*#__PURE__*/ y.createContext(yS);function xS(e=!0){let t=y.useContext(bS);if(t.setValidityData===Ai&&!e)throw Error(Pi(28));return t}function SS(e,t,n,r,i=!0,a){let{registerFieldControl:o}=xS(),s=Si(()=>Symbol());X(()=>{let c=s.current;i?o(c,{controlRef:e,getValue:r,id:t,name:a,value:n}):o(c,void 0)},[e,i,r,t,a,o,s,n]),X(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}let CS=/*#__PURE__*/ y.createContext({elementRef:{current:null},formRef:{current:{fields:/* @__PURE__ */ new Map}},errors:{},clearErrors:Ai,validationMode:`onSubmit`,submitCountRef:{current:0}});function wS(){return y.useContext(CS)}let TS=/*#__PURE__*/ y.createContext({controlId:void 0,registerControlId:Ai,resetControlId:Ai,labelId:void 0,setLabelId:Ai,messageIds:[],setMessageIds:Ai,getDescriptionProps:e=>e});function ES(){return y.useContext(TS)}function DS(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=ES(),o=_f(),s=Si(()=>Symbol()),c=y.useRef(!1),l=y.useRef(!1),u=$(()=>{c.current&&i!==Ai&&(c.current=!1,i(s.current,void 0))});return X(()=>{if(!n||i===Ai){u();return}let e;if(t!==void 0)l.current=!0,e=t;else if(l.current)e=o;else{a();return}e===void 0?u():(c.current=!0,i(s.current,e))},[t,n,i,a,o,s,u]),X(()=>u,[u]),(n?r:void 0)??t??o}function OS(e){return e==null?void 0:`${e}-popup`}function kS(e,t){return(n,r)=>n!=null&&e.contains(n,r,t)}let AS=zg;function jS(e,t=!1){let{overflowY:n}=Ea(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}let MS=Symbol(`none`),NS={value:MS,index:-1};function PS(e,t,n){let r=e.get(t);if(r!==void 0||n===aS)return r;for(let[r,i]of e)if(oS(r,t,n))return i}function FS(e){let{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:i,onSelectedValueChange:a,defaultInputValue:o,inputValue:s,open:c,defaultOpen:l=!1,selectionMode:u,onItemHighlighted:d,name:f,form:p,disabled:m=!1,readOnly:h=!1,required:g=!1,inputRef:_,grid:v=!1,items:b,filteredItems:x,filter:S,filterQuery:C,openOnInputClick:w=!0,autoHighlight:T=!1,keepHighlight:E=!1,highlightItemOnHover:D=!0,loopFocus:O=!0,itemToStringLabel:k,itemToStringValue:j,isItemEqualToValue:M=aS,virtualized:N=!1,inline:P=!1,fillInputOnItemPress:F=!0,modal:I=!1,limit:L=-1,autoComplete:R=`list`,formAutoComplete:z,locale:B,submitOnItemClick:V=!1}=e,{clearErrors:H}=wS(),{setDirty:U,validityData:ee,setFilled:te,name:ne,disabled:W,setTouched:re,setFocused:ie,validationMode:G,validation:K}=xS(),q=jf(),ae=DS({id:t}),oe=AS({locale:B}),se=Array.isArray(b)?null:b;if(se&&typeof se.label!=`function`)throw Error(Pi(100));let ce=se?se.data:b,le=se?.value,J=le?void 0:ce,ue=y.useMemo(()=>{if(!x||!le)return;let e=Pg(x),t=e.map(le),n;return{values:t,findItem(r,i){if(!n){n=/* @__PURE__ */ new Map;for(let r=0;r<t.length;r+=1)n.has(t[r])||n.set(t[r],e[r])}return PS(n,r,i)}}},[x,le]),de=y.useMemo(()=>se?e=>se.label(e,M,e=>{let t=ue?.findItem(e,M);return t==null?Ig(e,k):se.itemLabel(t)}):k,[se,k,ue,M]),fe=y.useMemo(()=>se?Object.assign(e=>se.itemLabel(e),{selected:e=>Ig(e,de)}):k,[se,de,k]);function pe(e){return Ig(e,de)}let[me,he]=y.useState(!1),[ge,_e]=y.useState(null),ve=y.useRef(ge),ye=y.useRef([]),be=y.useRef([]),xe=y.useRef(null),Se=y.useRef(null),Ce=y.useRef(null),we=y.useRef(null),Te=y.useRef(null),Ee=y.useRef(!1),De=y.useRef(null),Oe=y.useRef(null),ke=y.useRef(null),Ae=y.useRef(NS),je=y.useRef(null),Me=y.useRef([]),Ne=y.useRef(null),Pe=W||m,Fe=ne??f,Ie=u===`multiple`,Le=u===`single`,Re=s!==void 0||o!==void 0,ze=ce!==void 0,Be=x!==void 0,Ve;Ve=T===`always`?`always`:T?`input-change`:!1;let[He,Ue]=Qm({controlled:i,default:Ie?r??ji:r,name:`Combobox`,state:`selectedValue`}),We=y.useMemo(()=>S===null?()=>!0:S===void 0?kS(oe,fe):S,[S,oe,fe]),Ge=Si(()=>Re?o??``:Le?pe(He):``).current,[Ke,qe]=Qm({controlled:s,default:Ge,name:`Combobox`,state:`inputValue`}),[Je,Ye]=Qm({controlled:c,default:l,name:`Combobox`,state:`open`}),Xe=Ng(ce),Ze=!Je&&ge!==null?ge:String(Ke).trim(),Qe=Le?pe(He):``,$e=Le&&!me&&Ze!==``&&Qe.length===Ze.length&&oe.contains(Qe,Ze),et=$e?``:C??Ze,tt=ze&&Be&&$e&&(!se||se.hasValue(He,M)),nt=y.useMemo(()=>ce?Pg(ce):ji,[ce]),rt=y.useMemo(()=>{if(x&&!tt)return x;if(!ce)return ji;if(Xe){let e=ce,t=[],n=0;for(let r of e){if(L>-1&&n>=L)break;let e=L>-1?L-n:1/0,i=et===``?r.items.slice(0,e):[];if(et!==``)for(let t of r.items){if(i.length>=e)break;We(t,et,fe)&&i.push(t)}if(i.length>0){let e={...r,items:i};t.push(e),n+=i.length}}return t}if(et===``)return L>-1?nt.slice(0,L):nt;let e=[];for(let t of nt){if(L>-1&&e.length>=L)break;We(t,et,fe)&&e.push(t)}return e},[x,tt,ce,Xe,et,L,We,fe,nt]),it=y.useMemo(()=>{if(ue&&rt===x)return ue.values;let e=Pg(rt);return le?e.map(e=>le(e)):e},[rt,x,ue,le]),at=Si(()=>{let e=null;return P&&Je&&ze&&u!==`none`&&(e=dS(it,He,M,Ie)),new Du({id:ae,labelId:void 0,selectedValue:He,open:Je,items:J,selectionMode:u,name:Fe,form:p,disabled:Pe,readOnly:h,required:g,grid:v,virtualized:N,openOnInputClick:w,itemToStringLabel:de,isItemEqualToValue:M,modal:I,autoHighlight:Ve,submitOnItemClick:V,hasInputValue:Re,mounted:!1,forceMounted:!1,transitionStatus:`idle`,inline:P,activeIndex:null,selectedIndex:e,popupProps:{},listProps:{},inputProps:{},triggerProps:{},itemRoot:{props:Mi,id:ae,selectionMode:u,disabled:Pe,readOnly:h,isItemEqualToValue:M},positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:u===`none`},{onOpenChangeComplete:Ai,setOpen:Ai,setInputValue:Ai,setSelectedValue:Ai,setIndices:Ai,handleSelection:Ai,forceMount:Ai,requestSubmit:Ai,listRef:ye,labelsRef:be,popupRef:xe,emptyRef:Te,inputRef:Se,startDismissRef:Ce,endDismissRef:we,chipsContainerRef:De,clearRef:Oe,valuesRef:Me,pointerDownItemRef:Ne,selectionEventRef:ke},mS)}).current,ot=u===`none`?Ke:He,st=y.useMemo(()=>u===`none`?ot:Array.isArray(He)?He.map(e=>Lg(e,j)):Lg(He,j),[ot,j,u,He]),ct=$(d),lt=$(n),ut=at.useState(`activeIndex`),dt=at.useState(`selectedIndex`),ft=at.useState(`positionerElement`),pt=at.useState(`listElement`),mt=at.useState(`triggerElement`),ht=at.useState(`inputElement`),gt=at.useState(`inputGroupElement`),_t=at.useState(`inline`),vt=at.useState(`inputInsidePopup`),yt=at.useState(`inputOwnsFormValue`),bt=Le&&!vt&&Ke===Qe,xt=Vo(mt),{openMethod:St,triggerProps:Ct}=qp(Je),wt=$(()=>st);SS(vt?xt:Se,ae,ot,wt,!Pe,f);let Tt=$(()=>{ce?be.current=it.map(pe):at.set(`forceMounted`,!0)}),Et=$((e,t,n,r)=>{if(t===-1){if(Ae.current===NS)return;Ae.current=NS}else Ae.current={value:e,index:t};ct(e,fo(n,r,{index:t}))}),Dt=$(e=>{let t={};e.activeIndex!==void 0&&(t.activeIndex=e.activeIndex),e.selectedIndex!==void 0&&(t.selectedIndex=e.selectedIndex),at.update(t);let n=e.activeIndex;if(n===void 0)return;let r=e.type||`none`;n===null?Et(void 0,-1,r,e.event):Et(Me.current[n],n,r,e.event)}),Ot=$((t,n)=>{if(e.onInputValueChange?.(t,n),!n.isCanceled){if(Ee.current=n.reason===bo,n.reason===`input-change`){Je&&ge!==null&&_e(null);let e=n.event,r=e.inputType;if(e.type===`compositionend`||r!=null&&r!==``&&r!==`insertReplacementText`){let e=t.trim()!==``;e&&he(!0),je.current={hasQuery:e};let n=at.state.listElement;if(!at.state.virtualized&&n){let e=xe.current;for(let t of Aa(n.firstElementChild??n)){if(!pa(t)||(e?!Z(e,t):t.getAttribute(`role`)===`dialog`))break;if(jS(t)){t.scrollTop=0;break}}}e&&Ve&&at.state.activeIndex==null&&(Je||_t)&&at.set(`activeIndex`,0)}}else n.reason===`input-clear`&&t===``&&at.state.inputInsidePopup&&(je.current={hasQuery:!1,selection:!0});qe(t)}}),kt=$(e=>{let t=!e&&vt&&!_t&&Ke!==``&&(String(Ke).trim()===ge||Ke===Qe);!e&&(t||Ke===``||bt)&&he(!1),_e(null),t&&Ot(``,Q(bo))}),[At,jt]=y.useState(!1),Mt=$((t,n)=>{if(Je===t)return;n.reason===`escape-key`&&ze&&it.length===0&&!Te.current&&n.allowPropagation();let r=n,i=su(r);if(e.onOpenChange?.(t,r),je.current?.hasQuery&&n.reason===`input-change`===n.isCanceled&&(je.current=null),!n.isCanceled&&(t&&ge!==null&&kt(n.reason===yo),!t&&me&&(Le?(_t||_e(Ze),Ze===``&&he(!1)):Ie&&(_t||_e(Ze),vt&&Dt({activeIndex:null}),(!vt||_t)&&Ot(``,Q(bo,n.event,void 0,{isItemPress:n.reason===_o})))),t||jt(i()),Ye(t),!t&&vt&&(n.reason===`focus-out`||n.reason===`outside-press`)&&(re(!0),ie(!1),G===`onBlur`))){let e=u===`none`?Ke:He;K.commit(e)}}),Nt=$((e,t)=>{a?.(e,t),t.isCanceled||(Ue(e),(u===`none`&&xe.current&&F||Le&&!at.state.inputInsidePopup)&&Ot(pe(e),Q(t.reason,t.event)))}),Pt=$((e,t)=>{let n=Pa(e),r=ke.current??e;ke.current=null;let i=Q(_o,r),a=Na(n,`a`)?.getAttribute(`href`);if(a)a.startsWith(`#`)&&Mt(!1,i);else if(Ie){let e=Array.isArray(He)?He:[],n=cS(e,t,M),r=n?pS(e,t,M):[...e,t];if(Nt(r,i),i.isCanceled||!(Se.current&&Se.current.value.trim()!==``))return;if(at.state.inputInsidePopup){Ot(``,Q(bo,i.event,void 0,{isItemPress:!0}));let e=je.current;e&&!n&&(e.toggledValue=t)}else Mt(!1,i)}else{if(Nt(t,i),i.isCanceled)return;Mt(!1,i)}}),Ft=$(()=>{let e=K.inputRef.current?.form??at.state.inputElement?.form;e&&typeof e.requestSubmit==`function`&&e.requestSubmit()}),It=$(()=>{if(lt?.(!1),he(!1),_e(null),Dt(u===`none`?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),Ie&&Se.current&&Se.current.value!==``&&!Ee.current&&Ot(``,Q(bo)),Le){if(at.state.inputInsidePopup)Se.current&&Se.current.value!==``&&Ot(``,Q(bo));else{let e=pe(He);Se.current&&Se.current.value!==e&&Ot(e,Q(e===``?bo:po))}}}),Lt=y.useMemo(()=>_t&&ft?{current:Na(ft,`[role="dialog"]`)}:xe,[_t,ft]),{mounted:Rt,transitionStatus:zt,forceUnmount:Bt}=$l({open:Je,ref:Lt,preventUnmountOnClose:At,setPreventUnmountOnClose:jt,onUnmount:It});y.useImperativeHandle(e.actionsRef,()=>({unmount:Bt,close:()=>Mt(!1,Q(ko))}),[Bt,Mt]),X(function(){let e=ve.current!==null&&ge===null;if(ve.current=ge,Je&&(!e||!ze)||(Je||(Ne.current=null),u===`none`))return;let t=ze?it:Me.current;Dt({selectedIndex:dS(t,He,M,Ie)})},[Je,ge,He,u,Ie,ze,it,M,Dt]),X(()=>{ce&&(Me.current=it,ye.current.length=it.length)},[ce,it]),X(()=>{!Je&&je.current?.hasQuery&&(je.current=null)},[Je]),X(()=>{if(!Je&&_t&&Lt.current){je.current=null;return}let e=ze||Be?it:Me.current,t=je.current;if(t){let n=Je||_t||at.state.positionerElement?.hidden===!1;if(t.hasQuery){let t=Se.current;!Ve||String(Ke).trim()===``||_t&&Ve!==`always`&&(!t||Ma(t.ownerDocument)!==t)?je.current=null:n&&(e[0]!==void 0||!ze&&!Be)&&(at.set(`activeIndex`,0),je.current=null)}else if(String(Ke).trim()===``&&(je.current=null,n)){let e=t.selection;Ve===`always`&&!e&&at.state.selectionMode===`none`&&at.set(`activeIndex`,0),queueMicrotask(()=>{if(!at.state.open&&(!at.state.inline||Lt.current)||Se.current&&Se.current.value.trim()!==``)return;let n=at.state.selectedValue,r=at.state.selectionMode===`multiple`;if(r&&Array.isArray(n)?n.length>0:at.state.selectionMode!==`none`&&n!=null){let e=ze||Be?it:Me.current,i=lS(e,t.toggledValue,at.state.isItemEqualToValue);at.set(`activeIndex`,i===-1?dS(e,n,at.state.isItemEqualToValue,r):i)}else e?at.set(`activeIndex`,null):Ve===`always`&&at.set(`activeIndex`,0)})}}if(!Je&&!_t)return;let n=at.state.activeIndex;if(n==null){if(Ve===`always`&&e.length>0){at.set(`activeIndex`,0);return}Et(void 0,-1,po);return}if(n>=e.length){Et(void 0,-1,po),at.set(`activeIndex`,null);return}let r=e[n],i=Ae.current.value,a=i!==MS&&oS(r,i,at.state.isItemEqualToValue);Ae.current.index===n&&a||Et(r,n,po)},[ut,Ve,Et,Be,ze,it,_t,Je,Lt,at,Ke]),X(()=>{te(u===`none`?String(Ke)!==``:Ie?Array.isArray(He)&&He.length>0:He!=null)},[te,u,Ke,He,Ie]),y.useEffect(()=>{ze&&Ve&&it.length===0&&Dt({activeIndex:null})},[ze,Ve,it.length,Dt]);function Vt(){Je&&Ze!==``&&Ze!==String(Ge)&&!bt&&he(!0)}function Ht(){Je&&ge!==null&&kt(!1)}let Ut=!1;function Wt(){!Ut&&Ke!==Qe&&(Ut=!0,Ot(Qe,Q(po)))}function Gt(){u!==`none`&&(H(Fe),U(sS(He,ee.initialValue,M)),K.change(He),Le&&!Re&&!vt&&Wt())}function Kt(){Le&&!Re&&!vt&&!me&&Wt()}function qt(){u===`none`&&(H(Fe),U(Ke!==ee.initialValue),K.change(Ke))}Gp(Ze,Vt),Gp(Je,Ht),Gp(He,Gt),Gp(Qe,Kt),Gp(ce,Kt),Gp(Ke,qt);let Jt=Ru({open:_t?!0:Je,onOpenChange:Mt,elements:{reference:vt?mt:ht,floating:ft}}),Yt=v?`grid`:`listbox`,Xt=Je||_t,Zt=Xt?`true`:`false`,Qt=y.useMemo(()=>{let e=ht?.tagName===`INPUT`,t=ht==null||e,n=t||Xt,r=t?{autoComplete:`off`,spellCheck:`false`,autoCorrect:`off`,autoCapitalize:`none`}:{};return n&&(r.role=`combobox`,r[`aria-expanded`]=Zt,r[`aria-haspopup`]=Yt,r[`aria-controls`]=Xt?pt?.id:void 0,r[`aria-autocomplete`]=h?`none`:R),{reference:r,floating:{role:`presentation`}}},[ht,Xt,Zt,Yt,pt?.id,R,h]),$t=kl(Jt,{enabled:!Pe&&w,event:`mousedown-only`,toggle:!1,touchOpenDelay:vt?0:100,reason:xo}),en=Fl(Jt,{enabled:!Pe&&!_t,outsidePressEvent:{mouse:`sloppy`,touch:`intentional`},bubbles:_t?!0:void 0,outsidePress(e){let t=Pa(e);return!Z(mt,t)&&!Z(Oe.current,t)&&!Z(De.current,t)&&!Z(gt,t)}}),tn=td(Jt,{enabled:!Pe,id:ae,listRef:ye,activeIndex:ut,selectedIndex:dt,virtual:!0,loopFocus:O,allowEscape:O&&!Ve,focusItemOnOpen:me||u===`none`&&!Ve?!1:`auto`,focusItemOnHover:D,resetOnPointerLeave:!E,orientation:v?`horizontal`:void 0,rtl:q===`rtl`,disabledIndices:ji,grid:v?qx:void 0,onNavigate(e,t){(t||Je||_t&&e===null)&&zt!==`ending`&&Dt({activeIndex:e,type:rg(t),event:t?.nativeEvent})}}),nn=y.useMemo(()=>Fc(tn.reference,{onKeyDown(e){v&&at.state.activeIndex==null&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&e.preventBaseUIHandler()}},en.reference,$t.reference,Qt.reference),[tn.reference,en.reference,$t.reference,Qt.reference,v,at]),rn=y.useMemo(()=>Fc(eu,en.floating),[en.floating]),an=y.useMemo(()=>Fc(tn.floating,Qt.floating),[tn.floating,Qt.floating]),on=y.useMemo(()=>{let e=tn.item;return{props:e?{...e,onFocus:void 0}:Mi,id:ae,selectionMode:u,disabled:Pe,readOnly:h,isItemEqualToValue:M}},[tn.item,ae,u,Pe,h,M]);at.useContextCallback(`setOpen`,Mt),at.useContextCallback(`setInputValue`,Ot),at.useContextCallback(`setSelectedValue`,Nt),at.useContextCallback(`setIndices`,Dt),at.useContextCallback(`handleSelection`,Pt),at.useContextCallback(`forceMount`,Tt),at.useContextCallback(`requestSubmit`,Ft),at.useContextCallback(`onOpenChangeComplete`,n),Kx(()=>{at.update({inline:P,popupProps:rn,listProps:an,inputProps:nn,triggerProps:Ct,itemRoot:on})});let sn={id:ae,selectedValue:He,open:Je,mounted:Rt,transitionStatus:zt,items:J,inline:P,popupProps:rn,listProps:an,inputProps:nn,triggerProps:Ct,itemRoot:on,openMethod:St,selectionMode:u,name:Fe,form:p,disabled:Pe,readOnly:h,required:g,grid:v,virtualized:N,openOnInputClick:w,itemToStringLabel:de,modal:I,autoHighlight:Ve,isItemEqualToValue:M,submitOnItemClick:V,hasInputValue:Re};X(()=>{at.update({...sn,inputOwnsFormValue:u===`none`&&(P||!at.state.inputInsidePopup)})},[at,...Object.values(sn)]);let cn=Fo(_,K.inputRef),ln=y.useMemo(()=>({query:Ze,hasItems:ze,filteredItems:rt,flatFilteredValues:it}),[Ze,ze,rt,it]),un=y.useMemo(()=>Array.isArray(ot)?``:Lg(ot,j),[ot,j]),dn=Ie&&Array.isArray(He)&&He.length>0,fn=Ie||u===`none`&&yt?void 0:Fe,pn=y.useMemo(()=>!Ie||!Array.isArray(He)||!Fe?null:He.map(e=>{let t=Lg(e,j);return/*#__PURE__*/ (0,A.jsx)(`input`,{type:`hidden`,form:p,name:Fe,value:t,disabled:Pe},t)}),[Ie,He,p,Fe,j,Pe]),mn=/*#__PURE__*/ (0,A.jsxs)(y.Fragment,{children:[e.children,/*#__PURE__*/ (0,A.jsx)(`input`,{...K.getValidationProps(Pe,{onFocus(){vt?mt?.focus():(Se.current||mt)?.focus()},onChange(e){if(e.nativeEvent.defaultPrevented||Pe||h)return;let t=e.currentTarget.value,n=t.toLowerCase(),r=Q(po,e.nativeEvent),i=()=>Me.current.findIndex(e=>Lg(e,j).toLowerCase()===n||pe(e).toLowerCase()===n);function a(){if(Ie)return;if(u===`none`){Ot(t,r);return}let e=i();e===-1&&(e=Me.current.findIndex((e,t)=>{let r=be.current[t];return r!=null&&r.toLowerCase()===n}));let a=e===-1?void 0:Me.current[e];a!=null&&Nt?.(a,r)}Le&&(Tt(),ce&&i()===-1&&at.set(`forceMounted`,!0)),queueMicrotask(a)}}),id:ae&&fn==null?`${ae}-hidden-input`:void 0,form:p,name:fn,autoComplete:z,disabled:Pe,required:g&&!dn,readOnly:h,value:un,ref:cn,style:fn?es:$o,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),pn]});return/*#__PURE__*/ (0,A.jsx)(Jx.Provider,{value:at,children:/*#__PURE__*/ (0,A.jsx)(Yx.Provider,{value:Jt,children:/*#__PURE__*/ (0,A.jsx)(Zx.Provider,{value:ze,children:/*#__PURE__*/ (0,A.jsx)(Xx.Provider,{value:ln,children:/*#__PURE__*/ (0,A.jsx)(Qx.Provider,{value:Ke,children:mn})})})})})}function IS(e){let{multiple:t=!1,defaultValue:n,value:r,onValueChange:i,autoComplete:a,...o}=e;return/*#__PURE__*/ (0,A.jsx)(FS,{...o,selectionMode:t?`multiple`:`single`,selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:i,formAutoComplete:a})}function LS(e,t){return e??t}let RS={...Ja,...vS,popupSide:e=>e?{"data-popup-side":e}:null,listEmpty:e=>e?{"data-list-empty":``}:null};function zS(e,t,n){let{setFocused:r,focusOwnerRef:i}=xS(),a=$(t=>{(t?!e:i.current===a)&&(i.current=t&&a,n?.(t),r(t))});return X(()=>{let e=t.current;return e?.getRootNode()?.activeElement===e&&a(!0),()=>a(!1)},[e,t,a]),a}let BS=/*#__PURE__*/ y.createContext(void 0);function VS(){return y.useContext(BS)}let HS=/*#__PURE__*/ y.createContext(void 0);function US(e){let t=y.useContext(HS);if(t===void 0&&!e)throw Error(Pi(21));return t}let WS=/*#__PURE__*/ y.forwardRef(function(e,t){let n=$x(),{buttonRef:r,getButtonProps:i}=pp({native:!1}),a=Fo(t,r);function o(e){n.context.setOpen(!1,Q(vo,e.nativeEvent,e.currentTarget))}let s=i({onClick:o});return/*#__PURE__*/ (0,A.jsx)(`span`,{ref:a,...s,"aria-label":`Dismiss`,tabIndex:void 0,style:es})});function GS(e){let t=e.useState(`mounted`),n=e.useState(`popupSide`),r=e.useState(`positionerElement`);return t&&r?n:null}function KS(){return tS().filteredItems.length===0}function qS(e){return e===`rtl`?[`ArrowRight`,`ArrowLeft`]:[`ArrowLeft`,`ArrowRight`]}function JS(e,t){let n=e>=t-1?t-2:e;return n>=0?n:void 0}function YS(e,t,n){let r=e.context.listRef.current[t];r&&(e.context.selectionEventRef.current=n,r.click(),e.context.selectionEventRef.current=null)}let XS=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,id:a,style:o,...s}=e,{state:c,disabled:l,setTouched:u,validationMode:d,validation:f}=xS(),{labelId:p}=ES(),m=VS(),h=!!US(!0),g=$x(),_=nS(),v=jf(),b=g.useState(`required`),x=g.useState(`disabled`),S=g.useState(`readOnly`),C=g.useState(`name`),w=g.useState(`form`),T=g.useState(`selectionMode`),E=g.useState(`autoHighlight`),D=g.useState(`inputProps`),O=g.useState(`triggerProps`),k=g.useState(`open`),j=g.useState(`mounted`),M=g.useState(`selectedValue`),N=g.useState(`id`),P=g.useState(`inline`),F=g.useState(`modal`),I=!!E,L=GS(g),R=l||x||i,z=KS(),B=zS(R,g.context.inputRef),V=h||P,H=!V||F,U=_f(a??(V?void 0:N)),ee=h?gS:c,[te,ne]=y.useState(null),W=y.useRef(!1),re=y.useRef(null);X(()=>{k||(re.current=null)},[k]);let ie=T===`none`&&!h,G=$(e=>{let t=h||g.state.inline;t&&!g.state.hasInputValue&&g.context.setInputValue(``,Q(po)),g.update({inputElement:e,inputInsidePopup:t,inputOwnsFormValue:ie})}),K=h?s:f.getValidationProps(R,s);function q(e){g.context.setIndices({activeIndex:null,selectedIndex:null,type:rg(e),event:e})}let ae={...ee,open:k,disabled:R,readOnly:S,popupSide:L,listEmpty:z};function oe(e){if(!m)return;let t,n=m.chipsRef.current.length,[r]=qS(v);return e.key===r&&(e.currentTarget.selectionStart??0)===0&&M.length>0&&(e.preventDefault(),t=n>0?n-1:void 0),t}let se=Jc(`input`,e,{state:ae,ref:[t,g.context.inputRef,G],props:[D,O,{value:te??_,"aria-readonly":S||void 0,"aria-required":b||void 0,"aria-labelledby":p,disabled:R,readOnly:S,required:T===`none`?b:void 0,form:w,...ie&&C&&{name:C},id:U,onFocus(){if(B(!0),!P)return;let e=re.current;re.current=null,e!=null&&Object.hasOwn(g.context.valuesRef.current,e)&&g.context.setIndices({activeIndex:e})},onBlur(){u(!0),B(!1);let e=g.state.activeIndex;if(P&&e!==null&&E!==`always`&&(re.current=e,g.context.setIndices({activeIndex:null})),d===`onBlur`){let e=T===`none`?_:M;f.commit(e)}},onCompositionStart(e){Ji||(W.current=!0,ne(e.currentTarget.value))},onCompositionEnd(e){W.current=!1;let t=e.currentTarget.value;ne(null),g.context.setInputValue(t,Q(yo,e.nativeEvent))},onChange(e){let t=e.nativeEvent,n=t.inputType,r=!n||n===`insertReplacementText`,i=W.current||!r;function a(e){!S&&!R&&e&&i&&(g.context.setOpen(!0,Q(yo,t)),I||q(t))}if(W.current){let n=e.currentTarget.value;ne(n),n===``&&!g.state.openOnInputClick&&!g.state.inputInsidePopup&&g.context.setOpen(!1,Q(bo,t));let r=n.trim(),i=I&&r!==``;a(r),k&&g.state.activeIndex!==null&&!i&&q(t);return}let o=Q(yo,t);if(g.context.setInputValue(e.currentTarget.value,o),o.isCanceled)return;let s=e.currentTarget.value===``,c=Q(bo,t);s&&!g.state.inputInsidePopup&&(T===`single`&&g.context.setSelectedValue(null,c),g.state.openOnInputClick||g.context.setOpen(!1,c)),a(e.currentTarget.value.trim()),k&&g.state.activeIndex!==null&&!I&&q(t)},onKeyDown(e){if(e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;if(R||S){S&&e.key===`Enter`&&k&&g.state.activeIndex!==null&&ta(e);return}let t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r=v===`rtl`;if(e.key===`Home`){ta(e);let n=Qi&&r?t.value.length:0;t.setSelectionRange(n,n),t.scrollLeft=0;return}if(e.key===`End`){ta(e);let i=Qi&&r?0:t.value.length;t.setSelectionRange(i,i),t.scrollLeft=r?-n:n;return}if(!j&&e.key===`Escape`){let t=T===`multiple`&&Array.isArray(M)?M.length===0:M===null,n=Q(Co,e.nativeEvent),r=T===`multiple`?[]:null;g.context.setInputValue(``,n),g.context.setSelectedValue(r,n),t||g.state.inline||n.isPropagationAllowed||e.stopPropagation();return}if(m&&e.key===`Backspace`&&t.value===``&&Array.isArray(M)&&M.length>0){let t=m.chipsRef.current.length,n=t>0?t-1:M.length-1,r=M.filter((e,t)=>t!==n);q(e.nativeEvent),g.context.setSelectedValue(r,Q(po,e.nativeEvent));return}let i=oe(e);if(i!==void 0&&m?.chipsRef.current[i]?.focus(),e.which!==229&&e.key===`Enter`&&k){let t=g.state.activeIndex,n=e.nativeEvent;if(t===null){if(P)return;g.context.setOpen(!1,Q(po,n));return}ta(e),YS(g,t,n)}}},K],stateAttributesMapping:RS}),ce=h?/*#__PURE__*/ (0,A.jsx)(bS.Provider,{value:yS,children:se}):se;return/*#__PURE__*/ (0,A.jsxs)(y.Fragment,{children:[k&&H&&/*#__PURE__*/ (0,A.jsx)(WS,{ref:g.context.startDismissRef}),ce]})});function ZS(e,t,n,r){if(e.baseUIHandlerPrevented)return;let i=Pa(e.nativeEvent),a=fa(i)?i:null;(a===e.currentTarget||!r?.(a)&&!no(a))&&(e.preventDefault(),n||(t.context.inputRef.current?.focus(),t.state.openOnInputClick&&t.context.setOpen(!0,Q(xo,e.nativeEvent))))}let QS=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{state:o}=xS(),s=$x(),c=s.useState(`open`),l=s.useState(`disabled`),u=s.useState(`readOnly`),d=s.useState(`hasSelectedValue`),f=s.useState(`selectionMode`),p=GS(s),m=l,h=KS(),g=f!==`none`&&!d,_={...o,open:c,disabled:m,readOnly:u,popupSide:p,listEmpty:h,placeholder:g};return Jc(`div`,e,{ref:[t,$(e=>{s.set(`inputGroupElement`,e)})],props:[{role:`group`,onMouseDown(e){ZS(e,s,m,e=>Z(s.context.chipsContainerRef.current,e))}},a],state:_,stateAttributesMapping:RS})}),$S=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,nativeButton:i=!0,disabled:a=!1,id:o,style:s,...c}=e,{state:l,disabled:u,setTouched:d,validationMode:f,validation:p}=xS(),{labelId:m}=ES(),h=$x(),g=h.useState(`selectionMode`),_=h.useState(`disabled`),v=h.useState(`readOnly`),b=h.useState(`required`),x=h.useState(`positionerElement`),S=h.useState(`listElement`),C=h.useState(`popupId`),w=h.useState(`triggerProps`),T=h.useState(`inputInsidePopup`),E=h.useState(`id`),D=h.useState(`labelId`),O=h.useState(`open`),k=h.useState(`selectedValue`),A=h.useState(`activeIndex`),j=h.useState(`selectedIndex`),M=h.useState(`hasSelectedValue`),N=eS(),P=nS(),F=zi(),I=u||_||a,L=KS(),R=GS(h),z=y.useRef(null),B=zS(I,z);DS({id:T?o:void 0});let V=T?o??E:o,H=LS(m,D),U;O&&T?U=C??OS(E):O&&(U=S?.id);let ee=y.useRef(``);function te(e){ee.current=e.pointerType}let{reference:ne}=nd(N,{enabled:!O&&!v&&!_&&g===`single`,listRef:h.context.labelsRef,activeIndex:A,selectedIndex:j,onMatch(e){let t=h.context.valuesRef.current[e];t!==void 0&&h.context.setSelectedValue(t,Q(po))}}),{reference:W}=kl(N,{enabled:!_,event:`mousedown`}),{buttonRef:re,getButtonProps:ie}=pp({native:i,disabled:I}),G={...l,readOnly:v,open:O,disabled:I,popupSide:R,listEmpty:L,placeholder:g!==`none`&&!M};return Jc(`button`,e,{ref:[t,re,z,$(e=>{h.set(`triggerElement`,e)})],state:G,props:[w,W,ne,{id:V,tabIndex:T?0:-1,role:T?`combobox`:void 0,"aria-expanded":O,"aria-haspopup":T?`dialog`:`listbox`,"aria-controls":U,"aria-required":T&&b||void 0,"aria-readonly":T&&v||void 0,"aria-labelledby":H,onPointerDown:te,onPointerEnter:te,onFocus(){B(!0),I||F.start(0,h.context.forceMount)},onBlur(e){if(!Z(x,e.relatedTarget)&&(d(!0),B(!1),f===`onBlur`)){let e=g===`none`?P:k;p.commit(e)}},onMouseDown(e){if(I||(T||N.set(`domReferenceElement`,e.currentTarget),h.context.forceMount(),ee.current!==`touch`&&(h.context.inputRef.current?.focus(),T||e.preventDefault()),O))return;let t=Zo(e.currentTarget);function n(e){let t=h.state.triggerElement;if(!t)return;let n=Pa(e),r=h.state.positionerElement,i=h.state.listElement;Z(t,n)||Z(r,n)||Z(i,n)||hg(e,t)||h.context.setOpen(!1,Q(Do,e))}T&&t.addEventListener(`mouseup`,n,{once:!0})},onKeyDown(e){(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(ta(e),h.context.setOpen(!0,Q(wo,e.nativeEvent)),h.context.inputRef.current?.focus())}},p.getValidationProps(I,c),ie],stateAttributesMapping:RS})}),eC=/*#__PURE__*/ y.createContext(null);function tC(){return y.useContext(eC)}function nC(e){let{children:t}=e,{filteredItems:n}=tS(),r=tC(),i=r?r.items:n;return/*#__PURE__*/ (0,A.jsx)(y.Fragment,{children:i.map(t)})}let rC=/*#__PURE__*/ y.forwardRef(function(e,t){var n;let{render:r,className:i,style:a,children:o,...s}=e,c=$x(),l=eS(),u=!!US(!0),{filteredItems:d,hasItems:f}=tS(),p=c.useState(`selectionMode`),m=c.useState(`grid`),h=c.useState(`readOnly`),g=c.useState(`listProps`),_=c.useState(`virtualized`),v=c.useState(`forceMounted`),b=p===`multiple`,x=d.length===0,S=$(e=>{c.set(`positionerElement`,e)}),C=$(e=>{c.set(`listElement`,e)}),w=y.useMemo(()=>typeof o==`function`?n||=/*#__PURE__*/ (0,A.jsx)(nC,{children:o}):o,[o]),T={empty:x},E=l.useState(`floatingId`),D=Jc(`div`,e,{state:T,ref:[t,C,u?null:S],props:[g,{children:w,tabIndex:-1,id:E,role:m?`grid`:`listbox`,"aria-multiselectable":b?`true`:void 0,"aria-readonly":!m&&h?!0:void 0,onKeyDown(e){if(!(c.state.disabled||c.state.readOnly)&&e.key===`Enter`){let t=c.state.activeIndex;if(t==null)return;ta(e),YS(c,t,e.nativeEvent)}}},s]});if(_)return D;let O=f&&!v?void 0:c.context.labelsRef;return/*#__PURE__*/ (0,A.jsx)(Ih,{elementsRef:c.context.listRef,labelsRef:O,children:D})}),iC=/*#__PURE__*/ y.createContext(void 0);function aC(){let e=y.useContext(iC);if(e===void 0)throw Error(Pi(20));return e}let oC=/*#__PURE__*/ y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=$x(),a=i.useState(`mounted`),o=i.useState(`forceMounted`);return a||n||o?/*#__PURE__*/ (0,A.jsx)(iC.Provider,{value:n,children:/*#__PURE__*/ (0,A.jsx)(ul,{ref:t,...r})}):null}),sC=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m=!1,collisionAvoidance:h=rl,style:g,..._}=e,v=$x(),y=eS(),b=aC(),x=v.useState(`modal`),S=v.useState(`open`),C=v.useState(`mounted`),w=v.useState(`openMethod`),T=v.useState(`positionerElement`),E=v.useState(`triggerElement`),D=v.useState(`inputElement`),O=v.useState(`inputGroupElement`),k=v.useState(`inputInsidePopup`),j=v.useState(`transitionStatus`),M=KS(),N=Bf({anchor:i??(k?E:O??D),floatingRootContext:y,positionMethod:a,mounted:C,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m,keepMounted:b,collisionAvoidance:h,lazyFlip:!0});Wh(S&&x,w===`touch`,T,E);let P={open:S,side:N.side,align:N.align,anchorHidden:N.anchorHidden,empty:M};X(()=>{v.set(`popupSide`,N.side)},[v,N.side]);let F=$(e=>{v.set(`positionerElement`,e)}),I=Wf(e,P,{styles:N.positionerStyles,transitionStatus:j,props:_,refs:[t,F],hidden:!C,inert:!S});return/*#__PURE__*/ (0,A.jsxs)(HS.Provider,{value:N,children:[C&&x&&/*#__PURE__*/ (0,A.jsx)(Sp,{inert:Jf(!S),cutout:O??D??E}),I]})}),cC={...Ya,...Ba},lC=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=$x(),l=US(),u=eS(),d=c.useState(`mounted`),f=c.useState(`open`),p=c.useState(`openMethod`),m=c.useState(`popupProps`),h=c.useState(`transitionStatus`),g=c.useState(`inputInsidePopup`),_=c.useState(`inputElement`),v=c.useState(`modal`),b=c.useState(`id`),x=KS(),S=s.id??(g?OS(b):void 0);X(()=>(c.set(`popupId`,c.context.popupRef.current?.id||S),()=>{c.set(`popupId`,void 0)}),[c,S]),Ql({open:f,ref:c.context.popupRef,onComplete(){f&&c.context.onOpenChangeComplete(!0)}});let C=Jc(`div`,e,{state:{open:f,side:l.side,align:l.align,anchorHidden:l.anchorHidden,transitionStatus:h,empty:x},ref:[t,c.context.popupRef],props:[m,{id:S,role:g?`dialog`:`presentation`,onFocus(e){let t=Pa(e.nativeEvent);p!==`touch`&&(Z(c.state.listElement,t)||t===e.currentTarget)&&c.context.inputRef.current?.focus()}},Uf(h),s],stateAttributesMapping:cC}),w=a===void 0?g?e=>e===`touch`?c.context.popupRef.current:_:!1:a,T;T=o??(g?void 0:!1);let E=!g||v;return/*#__PURE__*/ (0,A.jsx)(Ol,{context:u,disabled:!d,modal:E,openInteractionType:p,initialFocus:w,returnFocus:T,getInsideElements:()=>[c.context.startDismissRef.current,c.context.endDismissRef.current],children:/*#__PURE__*/ (0,A.jsxs)(y.Fragment,{children:[C,E&&/*#__PURE__*/ (0,A.jsx)(WS,{ref:c.context.endDismissRef})]})})}),uC=/*#__PURE__*/ y.createContext(void 0),dC=/*#__PURE__*/ y.createContext(!1);function fC(){return y.useContext(dC)}function pC(e){let{componentProps:t,forwardedRef:n,virtualized:r,indexFromFilter:i}=e,{render:a,className:o,style:s,value:c=null,index:l,disabled:u=!1,nativeButton:d=!1,...f}=t,p=y.useRef(null),m=dh({guess:!0,index:l,textRef:p}),h=$x(),g=fC(),_=rS(),{props:v,id:x,selectionMode:S,disabled:C,readOnly:w,isItemEqualToValue:T}=h.useState(`itemRoot`),E=C||u,D=S!==`none`,O=l??i??m.index,k=O!==-1,j=h.useState(`isActive`,O),M=h.useState(`isSelected`,c),N=y.useRef(null),P=x!=null&&k?`${x}-${O}`:void 0,F=M&&D;X(()=>{if(!k||!r&&l==null)return;let e=h.context.listRef.current;return e[O]=N.current,()=>{delete e[O]}},[k,r,O,l,h]),X(()=>{if(!k||_)return;let e=h.context.valuesRef.current;return e[O]=c,()=>{delete e[O]}},[k,_,O,c,h]),X(()=>{if(!k||_)return;let e=h.state.selectedValue,t=h.state.selectedIndex;h.state.selectionMode===`multiple`&&Array.isArray(e)?t=fS(O,c,h.context.valuesRef.current,e,T,t):oS(c,e,T)&&(t=O),h.set(`selectedIndex`,t)},[k,_,h,O,c,T]);let{getButtonProps:I,buttonRef:L}=pp({disabled:E,focusableWhenDisabled:!0,native:d,composite:!0}),R={disabled:E,selected:F,highlighted:j};function z(e){function t(){h.context.handleSelection(e,c)}h.state.submitOnItemClick?(b.flushSync(t),h.context.requestSubmit()):t()}let B={id:P,role:g?`gridcell`:`option`,"aria-selected":D?F:void 0,tabIndex:void 0,onPointerDownCapture(e){e.isPrimary&&(h.context.pointerDownItemRef.current=e.currentTarget),e.preventDefault()},onMouseDown(e){e.preventDefault()},onClick(e){E||w||z(e.nativeEvent)},onMouseUp(e){let t=h.context.pointerDownItemRef.current===e.currentTarget;h.context.pointerDownItemRef.current=null,E||w||e.button!==0||t||!j||z(e.nativeEvent)}},V=Jc(`div`,t,{ref:[L,n,m.ref,N],state:R,props:[v,B,f,I]}),H=y.useMemo(()=>({selected:F,textRef:p}),[F,p]);return/*#__PURE__*/ (0,A.jsx)(uC.Provider,{value:H,children:V})}function mC(e){let{componentProps:t,forwardedRef:n}=e,r=$x().useState(`isItemEqualToValue`),{flatFilteredValues:i}=tS(),a=lS(i,t.value??null,r);return/*#__PURE__*/ (0,A.jsx)(pC,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:a})}let hC=/*#__PURE__*/ y.memo(/*#__PURE__*/ y.forwardRef(function(e,t){let n=$x().useState(`virtualized`);return n&&e.index==null?/*#__PURE__*/ (0,A.jsx)(mC,{componentProps:e,forwardedRef:t}):/*#__PURE__*/ (0,A.jsx)(pC,{componentProps:e,forwardedRef:t,virtualized:n,indexFromFilter:void 0})})),gC=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=$x(),s=o.useState(`hasSelectionChips`),c=y.useRef([]),l=Jc(`div`,e,{ref:[t,o.context.chipsContainerRef],props:[s?{role:`toolbar`}:Mi,{onMouseDown(e){ZS(e,o,o.state.disabled)}},a]}),u=y.useMemo(()=>({chipsRef:c}),[]);return/*#__PURE__*/ (0,A.jsx)(BS.Provider,{value:u,children:/*#__PURE__*/ (0,A.jsx)(Ih,{elementsRef:c,children:l})})}),_C=/*#__PURE__*/ y.createContext(void 0);function vC(){let e=y.useContext(_C);if(!e)throw Error(Pi(17));return e}let yC=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=$x(),{chipsRef:s}=VS(),c=jf(),l=o.useState(`disabled`),u=o.useState(`readOnly`),d=o.useState(`selectedValue`),{ref:f,index:p}=dh();function m(e){let t=p,[n,r]=qS(c);return e.key===n?(e.preventDefault(),t=p>0?p-1:void 0):e.key===r?(e.preventDefault(),t=p<s.current.length-1?p+1:void 0):e.key===`Backspace`||e.key===`Delete`?(t=JS(p,d.length),ta(e),b.flushSync(()=>{o.context.setIndices({activeIndex:null,selectedIndex:null,type:To,event:e.nativeEvent}),o.context.setSelectedValue(d.filter((e,t)=>t!==p),Q(po,e.nativeEvent))})):e.key===`Enter`||e.key===` `?(ta(e),t=void 0):e.key===`ArrowDown`||e.key===`ArrowUp`?(ta(e),b.flushSync(()=>{o.context.setOpen(!0,Q(wo,e.nativeEvent))}),t=void 0):e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey||(t=void 0),t}let h=Jc(`div`,e,{ref:[t,f],state:{disabled:l},props:[{tabIndex:-1,"aria-disabled":l||void 0,"aria-readonly":u||void 0,onKeyDown(e){if(l||u)return;let t=m(e);t===void 0?o.context.inputRef.current?.focus():s.current[t]?.focus()}},a]}),g=y.useMemo(()=>({index:p}),[p]);return/*#__PURE__*/ (0,A.jsx)(_C.Provider,{value:g,children:h})}),bC=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,nativeButton:a=!0,style:o,...s}=e,c=$x(),{index:l}=vC(),u=c.useState(`disabled`),d=c.useState(`readOnly`),f=c.useState(`selectedValue`),p=c.useState(`isItemEqualToValue`),m=u||i,{buttonRef:h,getButtonProps:g}=pp({native:a,disabled:m||d,focusableWhenDisabled:!0}),_={disabled:m};function v(e,t){let n=c.state.activeIndex;if(n==null)return;let r=lS(c.context.valuesRef.current,e,p);r!==-1&&n===r&&c.context.setIndices({activeIndex:null,type:rg(t),event:t})}function y(e){let t=Q(`chip-remove-press`,e.nativeEvent),n=f[l];return v(n,e.nativeEvent),c.context.setSelectedValue(f.filter((e,t)=>t!==l),t),c.context.inputRef.current?.focus(),t}return Jc(`button`,e,{ref:[t,h],state:_,props:[{tabIndex:-1,onMouseDown(e){e.preventDefault()},onClick(e){y(e).isPropagationAllowed||e.stopPropagation()},onKeyDown(e){e.key!==`Enter`&&e.key!==` `||y(e).isPropagationAllowed||ta(e)}},s,g]})}),xC=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,{filteredItems:s}=tS(),c=$x(),l=Vg(),u=s.length===0?a:null;return Jc(`div`,e,{ref:[t,c.context.emptyRef,l],props:[{children:u,role:`status`,"aria-live":`polite`,"aria-atomic":!0},o]})});ir(),ti(rr);let SC=`\0create:`;function CC({label:e,options:t,value:n,onChange:r,creatable:i,maxChips:a=2,placeholder:o,emptyText:s,error:c,className:l}){let u=y.useId(),[d,f]=y.useState(``),p=y.useMemo(()=>new Map(t.map(e=>[e.value,e.label])),[t]),m=e=>e.startsWith(SC)?w(`新增「{q}」`,{q:e.slice(8)}):p.get(e)??e,h=d.trim(),g=t.some(e=>e.label===h)||n.includes(h),_=[...t.map(e=>e.value),...n.filter(e=>!p.has(e)),...i&&h&&!g?[SC+h]:[]],v=n.slice(0,a),b=n.length-v.length;return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-field`,c&&`has-error`,l),children:[e?/* @__PURE__ */ (0,A.jsx)(N_,{htmlFor:u,children:e}):null,/* @__PURE__ */ (0,A.jsxs)(IS,{multiple:!0,autoHighlight:!0,items:_,value:n,inputValue:d,onInputValueChange:f,itemToStringLabel:m,onValueChange:e=>{r(e.map(e=>e.startsWith(SC)?e.slice(8):e)),f(``)},children:[/* @__PURE__ */ (0,A.jsxs)(QS,{className:M(`ui-ms`,c&&`is-invalid`),children:[/* @__PURE__ */ (0,A.jsxs)(gC,{className:`ui-ms-chips`,children:[v.map(e=>/* @__PURE__ */ (0,A.jsxs)(yC,{className:`ui-chip`,"aria-label":m(e),children:[m(e),/* @__PURE__ */ (0,A.jsx)(bC,{className:`ui-chip-x`,"aria-label":w(`移除 {name}`,{name:m(e)}),children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`x`,size:12})})]},e)),b>0?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-chip-more`,title:n.slice(a).map(m).join(`、`),children:`+`+b}):null,/* @__PURE__ */ (0,A.jsx)(XS,{id:u,className:`ui-ms-input`,"aria-invalid":c?!0:void 0,"aria-describedby":c?u+`-err`:void 0,placeholder:n.length?``:o||w(`搜尋`),onKeyDown:e=>{e.key===`Backspace`&&!d&&n.length&&(e.preventBaseUIHandler(),r(n.slice(0,-1)))}})]}),c?/* @__PURE__ */ (0,A.jsx)(F_,{inline:!0}):null]}),/* @__PURE__ */ (0,A.jsx)(oC,{children:/* @__PURE__ */ (0,A.jsx)(sC,{className:`ui-float is-match`,align:`start`,sideOffset:6,children:/* @__PURE__ */ (0,A.jsxs)(lC,{className:`ui-select-menu ui-ms-menu`,children:[/* @__PURE__ */ (0,A.jsx)(xC,{className:`ui-select-empty`,children:s||w(`找不到符合的選項`)}),/* @__PURE__ */ (0,A.jsx)(rC,{children:e=>e.startsWith(SC)?/* @__PURE__ */ (0,A.jsx)(hC,{value:e,className:`ui-select-opt ui-ms-create`,children:m(e)},e):/* @__PURE__ */ (0,A.jsxs)(hC,{value:e,className:M(`ui-select-opt`,`ui-ms-opt`,n.includes(e)&&`is-on`),children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-check-box`,n.includes(e)&&`is-on`),"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(P_,{v:n.includes(e)})}),/* @__PURE__ */ (0,A.jsx)(`span`,{children:m(e)})]},e)})]})})})]}),/* @__PURE__ */ (0,A.jsx)(I_,{id:u+`-err`,error:c})]})}De(),ti(Ee);function wC({items:e,onOpen:t,onReadAll:n,emptyText:r}){let[i,a]=y.useState(!1),o=e.filter(e=>!e.read).length,s=[];for(let t of e){let e=t.group||``,n=s[s.length-1];!n||n.title!==e?s.push({title:e,items:[t]}):n.items.push(t)}return/* @__PURE__ */ (0,A.jsxs)(wv,{open:i,onOpenChange:a,align:`end`,sideOffset:8,className:`ui-noti`,"aria-label":w(`通知`),trigger:/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-iconbtn`,`ui-bell`,i&&`is-open`),"aria-label":o?w(`通知,{n} 則未讀`,{n:o}):w(`通知`),children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`bell`}),o?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-badge-count`,"aria-hidden":`true`,children:o>99?`99+`:o}):null]}),children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-noti-head`,children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-noti-title`,children:w(`通知`)}),o&&n?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-noti-readall`,onClick:n,children:w(`全部標為已讀`)}):null]}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-noti-list`,children:e.length?s.map((e,n)=>/* @__PURE__ */ (0,A.jsxs)(y.Fragment,{children:[e.title?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-noti-group`,children:e.title}):null,e.items.map(e=>/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-noti-item`,!e.read&&`is-unread`),onClick:()=>t?.(e),children:[e.read?null:/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-noti-dot`,"aria-hidden":`true`}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:w(`未讀`)+w(`,`)})]}),/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-noti-text`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-noti-t`,children:e.title}),e.body?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-noti-b`,children:im(e.body)}):null,e.time?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-noti-time`,children:e.time}):null]})]},e.id))]},n)):/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-noti-empty`,children:r||w(`沒有通知`)})})]})}function TC({label:e,icon:t,count:n,title:r,side:i=`bottom`,align:a=`end`,children:o,triggerClassName:s}){let[c,l]=y.useState(!1);return/* @__PURE__ */ (0,A.jsxs)(wv,{open:c,onOpenChange:l,openOnHover:!0,side:i,align:a,sideOffset:10,className:`ui-popover`,"aria-label":r?void 0:e,trigger:/* @__PURE__ */ (0,A.jsxs)(`button`,{type:`button`,className:M(`ui-btn`,`ui-btn-secondary`,s),children:[t?/* @__PURE__ */ (0,A.jsx)(fi,{icon:t}):null,e,n?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-pop-count`,children:n}):null]}),children:[/* @__PURE__ */ (0,A.jsx)(xv,{className:`ui-popover-arrow`}),r?/* @__PURE__ */ (0,A.jsx)(Sv,{className:`ui-popover-title`,children:r}):null,/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-popover-body`,children:typeof o==`function`?o(()=>l(!1)):o})]})}function EC({value:e,label:t,size:n=72,className:r}){let i=(n-8)/2,a=2*Math.PI*i,o=Math.max(0,Math.min(100,e||0)),s=v_(o,900),c=n/2;return/* @__PURE__ */ (0,A.jsxs)(`svg`,{className:M(`ui-ring`,r),width:n,height:n,viewBox:`0 0 ${n} ${n}`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(o),"aria-label":t,children:[/* @__PURE__ */ (0,A.jsx)(`circle`,{cx:c,cy:c,r:i,className:`ui-ring-track`,strokeWidth:8}),/* @__PURE__ */ (0,A.jsx)(`circle`,{cx:c,cy:c,r:i,className:`ui-ring-fill`,strokeWidth:8,strokeDasharray:`${(a*o/100*s).toFixed(1)} ${a.toFixed(1)}`,transform:`rotate(-90 ${c} ${c})`}),/* @__PURE__ */ (0,A.jsx)(`text`,{x:c,y:c+5,textAnchor:`middle`,className:`ui-ring-text`,children:Math.round(o*s)+`%`})]})}je(),ti(Ae);let DC={live:`即時`,stale:`已過期`,offline:`離線`};function OC({project:e,status:t=`live`,statusLabel:n,options:r=[],value:i,onChange:a,footer:o,className:s}){let c=DC[t]?t:`live`,l=n||w(DC[c]),u=`${e} · ${l}`,d=/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-projsw-dot`,"aria-hidden":`true`}),/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-projsw-text`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-projsw-name`,children:e}),/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-projsw-status`,children:[` · `,l]})]})]});return!r.length||!a?/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-projsw`,`is-`+c,`is-static`,s),role:`status`,"aria-label":u,title:u,children:d}):/* @__PURE__ */ (0,A.jsxs)(fg,{children:[/* @__PURE__ */ (0,A.jsxs)(Sg,{className:M(`ui-projsw`,`is-`+c,s),"aria-label":w(`切換專案,目前是 {name}`,{name:u}),title:u,children:[d,/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-down`,size:14,className:`ui-projsw-caret`})]}),/* @__PURE__ */ (0,A.jsx)(Fh,{children:/* @__PURE__ */ (0,A.jsx)(Gh,{className:`ui-float`,side:`bottom`,align:`end`,sideOffset:6,children:/* @__PURE__ */ (0,A.jsxs)(Mh,{className:`ui-projsw-pop`,"aria-label":w(`切換專案`),children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-projsw-title`,children:w(`切換專案`)}),/* @__PURE__ */ (0,A.jsx)(Yh,{value:i,onValueChange:e=>e!==i&&a(e),children:r.map(e=>/* @__PURE__ */ (0,A.jsxs)($h,{value:e.id,closeOnClick:!0,className:M(`ui-projsw-opt`,e.id===i&&`is-on`),children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-projsw-optlabel`,children:e.label}),e.detail?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-projsw-optdetail`,children:e.detail}):null,/* @__PURE__ */ (0,A.jsx)(eg,{className:`ui-projsw-check`,children:/* @__PURE__ */ (0,A.jsx)(Y,{d:pi,size:16})})]},e.id))}),o?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-projsw-foot`,children:o}):null]})})})]})}function kC({label:e,value:t,onChange:n,options:r,disabled:i,className:a}){let o=y.useRef([]),s=r.map(e=>!(i||e.disabled)),c=r.findIndex(e=>e.value===t),l=c>=0?c:s.indexOf(!0),u=(e,t)=>{for(let i=1;i<=r.length;i++){let a=(e+t*i+r.length)%r.length;if(s[a]){o.current[a]?.focus(),n?.(r[a].value);return}}};return/* @__PURE__ */ (0,A.jsxs)(`div`,{role:`radiogroup`,"aria-label":e,className:M(`ui-radios`,a),children:[e?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-field-label`,children:e}):null,r.map((e,r)=>{let i=t===e.value;return/* @__PURE__ */ (0,A.jsxs)(`button`,{ref:e=>{o.current[r]=e},type:`button`,role:`radio`,"aria-checked":i,tabIndex:r===l?0:-1,disabled:!s[r],className:M(`ui-radio`,i&&`is-on`),onClick:()=>n?.(e.value),onKeyDown:e=>{W(e)||(e.key===`ArrowDown`||e.key===`ArrowRight`?(e.preventDefault(),u(r,1)):(e.key===`ArrowUp`||e.key===`ArrowLeft`)&&(e.preventDefault(),u(r,-1)))},children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-radio-ring`,"aria-hidden":`true`,children:i?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-radio-dot`}):null}),/* @__PURE__ */ (0,A.jsx)(`span`,{children:e.label})]},e.value)})]})}let AC=/*#__PURE__*/ y.createContext(void 0),jC=/*#__PURE__*/ y.createContext(void 0);function MC(){let e=y.useContext(AC);if(e===void 0)throw Error(Pi(60));return e}function NC(){let e=y.useContext(jC);if(e===void 0)throw Error(Pi(61));return e}let PC={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,multiple:e=>e.multiple,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,highlightItemOnHover:e=>e.highlightItemOnHover,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:Lg(t,r)!==``},hasNullItemLabel:(e,t)=>t?Fg(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>oS(t,e,n)):oS(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,itemRoot:e=>e.itemRoot,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows};function FC(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}function IC(e,t){return Math.max(0,e-t)}function LC(e,t){if(t<=0)return 0;let n=FC(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}function RC(e){let{id:t,value:n,defaultValue:r=null,onValueChange:i,open:a,defaultOpen:o=!1,onOpenChange:s,name:c,form:l,autoComplete:u,disabled:d=!1,readOnly:f=!1,required:p=!1,modal:m=!0,actionsRef:h,inputRef:g,onOpenChangeComplete:_,items:v,multiple:b=!1,itemToStringLabel:x,itemToStringValue:S,isItemEqualToValue:C=aS,highlightItemOnHover:w=!0,children:T}=e,{clearErrors:E}=wS(),{setDirty:D,setTouched:O,setFocused:k,validityData:j,setFilled:M,name:N,disabled:P,validation:F,validationMode:I}=xS(),L=DS({id:t}),R=P||d,z=N??c,[B,V]=Qm({controlled:n,default:b?r??ji:r,name:`Select`,state:`value`}),[H,U]=Qm({controlled:a,default:o,name:`Select`,state:`open`}),ee=y.useRef([]),te=y.useRef([]),ne=y.useRef(null),W=y.useRef(null),re=y.useRef(0),ie=y.useRef(null),G=y.useRef([]),K=y.useRef(!1),q=y.useRef(null),ae=y.useRef(null),oe=y.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),se=y.useRef(!1),ce=y.useRef(B),{openMethod:le,triggerProps:J}=qp(H),ue=Si(()=>new Du({id:L,labelId:void 0,modal:m,multiple:b,disabled:R,readOnly:f,required:p,highlightItemOnHover:w,itemToStringLabel:x,itemToStringValue:S,isItemEqualToValue:C,value:B,open:H,mounted:H,transitionStatus:void 0,items:v,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:Mi,triggerProps:Mi,itemRoot:{props:Mi,multiple:b,disabled:R,readOnly:f,isItemEqualToValue:C},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:Ai,setOpen:Ai,handleScrollArrowVisibility:Ai,onOpenChangeComplete:Ai,listRef:ee,popupRef:ne,scrollHandlerRef:W,scrollArrowsMountedCountRef:re,valueRef:ie,valuesRef:G,labelsRef:te,typingRef:K,selectionRef:oe,firstItemTextRef:q,selectedItemTextRef:ae,alignItemWithTriggerActiveRef:se,initialValueRef:ce},PC)).current,[de,fe]=y.useState(!1),{mounted:pe,transitionStatus:me,forceUnmount:he}=$l({open:H,ref:ne,preventUnmountOnClose:de,setPreventUnmountOnClose:fe,onUnmount(){ue.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),_?.(!1)}}),ge=ue.useState(`activeIndex`),_e=ue.useState(`selectedIndex`),ve=ue.useState(`triggerElement`),ye=ue.useState(`positionerElement`),be=Yf(le),xe=le??be,Se=y.useMemo(()=>b?``:Lg(B,S),[b,B,S]),Ce=y.useMemo(()=>b&&Array.isArray(B)?B.map(e=>Lg(e,S)):Lg(B,S),[b,B,S]);SS(Vo(ve),L,B,$(()=>Ce),!R,c);let we=b?Array.isArray(B)&&B.length>0:B!=null&&Se!==``;X(()=>{M(we)},[we,M]),X(function(){let e=dS(G.current,B,C,b);e===null&&(ae.current=null),H||ue.set(`selectedIndex`,e)},[b,H,B,C,ue]),Gp(B,()=>{E(z),D(sS(B,j.initialValue,C)),F.change(B)});let Te=$((e,t)=>{let n=t,r=su(n);s?.(e,n),t.isCanceled||(e||fe(r()),U(e),e||t.reason!==`focus-out`&&t.reason!==`outside-press`||(O(!0),k(!1),I===`onBlur`&&F.commit(B)))});y.useImperativeHandle(h,()=>({unmount:he,close:()=>{ue.state.open&&Te(!1,Q(ko))}}),[he,Te,ue]);let Ee=$((e,t)=>{i?.(e,t),t.isCanceled||V(e)}),De=$(e=>{let t=IC(e.scrollHeight,e.clientHeight),n=LC(e.scrollTop,t),r=n>0,i=n<t;ue.set(`scrollUpArrowVisible`,r),ue.set(`scrollDownArrowVisible`,i)}),Oe=Ru({open:H,onOpenChange:Te,elements:{reference:ve,floating:ye}}),ke=kl(Oe,{enabled:!R,event:`mousedown`}),Ae=Fl(Oe),je=td(Oe,{enabled:!R,listRef:ee,activeIndex:ge,selectedIndex:_e,disabledIndices:ji,onNavigate(e){(e!==null||H)&&ue.set(`activeIndex`,e)},focusItemOnHover:w}),Me=nd(Oe,{enabled:!R&&(H||!f&&!b),listRef:te,activeIndex:ge,selectedIndex:_e,disabledIndices:e=>Eg(ee.current[e]),onMatch(e){H?ue.set(`activeIndex`,e):Ee(G.current[e],Q(po))},onTyping(e){K.current=e}}),Ne=y.useMemo(()=>Fc(Me.reference,je.reference,Ae.reference,ke.reference,J),[ke.reference,Me.reference,je.reference,Ae.reference,J]),Pe=y.useMemo(()=>Fc(eu,Me.floating,je.floating,Ae.floating),[Me.floating,je.floating,Ae.floating]),Fe=je.item??Mi,Ie=y.useMemo(()=>({props:Fe,multiple:b,disabled:R,readOnly:f,isItemEqualToValue:C}),[Fe,b,R,f,C]);ue.useContextCallback(`setValue`,Ee),ue.useContextCallback(`setOpen`,Te),ue.useContextCallback(`handleScrollArrowVisibility`,De),ue.useContextCallback(`onOpenChangeComplete`,_),Kx(()=>{ue.update({popupProps:Pe,triggerProps:Ne,itemRoot:Ie})}),ue.useSyncedValues({id:L,modal:m,multiple:b,disabled:R,readOnly:f,required:p,highlightItemOnHover:w,value:B,open:H,mounted:pe,transitionStatus:me,popupProps:Pe,triggerProps:Ne,itemRoot:Ie,items:v,itemToStringLabel:x,itemToStringValue:S,isItemEqualToValue:C,openMethod:xe});let Le=Fo(g,F.inputRef),Re=b?void 0:z,ze=y.useMemo(()=>!b||!Array.isArray(B)||!z?null:B.map(e=>{let t=Lg(e,S);return/*#__PURE__*/ (0,A.jsx)(`input`,{type:`hidden`,form:l,name:z,value:t,disabled:R},t)}),[b,B,l,z,S,R]);return/*#__PURE__*/ (0,A.jsxs)(AC.Provider,{value:ue,children:[/*#__PURE__*/ (0,A.jsx)(jC.Provider,{value:Oe,children:T}),/*#__PURE__*/ (0,A.jsx)(`input`,{...F.getValidationProps(R,{onFocus(){ue.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||R||f)return;let t=e.currentTarget.value,n=Q(po,e.nativeEvent);function r(){if(b)return;let e=t.toLowerCase(),r=G.current.findIndex(t=>Lg(t,S).toLowerCase()===e||Ig(t,x).toLowerCase()===e);r===-1&&(r=G.current.findIndex((t,n)=>{let r=te.current[n];return r!=null&&r.toLowerCase()===e}));let i=G.current[r];i!=null&&Ee(i,n)}ue.set(`forceMount`,!0),queueMicrotask(r)}}),id:L&&Re==null?`${L}-hidden-input`:void 0,form:l,name:Re,autoComplete:u,value:Se,disabled:R,required:p&&!(b&&we),readOnly:f,ref:Le,style:z?es:$o,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),ze]})}let zC={...Ja,...vS,popupSide:e=>e?{"data-popup-side":e}:null,value:()=>null},BC=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{setTouched:l,validationMode:u,validation:d,state:f,disabled:p}=xS(),{labelId:m}=ES(),h=MC(),g=h.useState(`readOnly`),_=h.useState(`required`),v=h.useState(`disabled`),b=p||v||a,x=h.useState(`open`),S=h.useState(`mounted`),C=h.useState(`value`),w=h.useState(`triggerProps`),T=h.useState(`positionerElement`),E=h.useState(`listElement`),D=h.useState(`popupSide`),O=h.useState(`id`),k=h.useState(`labelId`),A=h.useState(`hasSelectedValue`),j=S&&T?D:null,M=i??O,N=LS(m,k);DS({id:i});let P=Vo(T),F=y.useRef(null),I=zS(b,F),{getButtonProps:L,buttonRef:R}=pp({disabled:b,native:o}),z=h.useStateSetter(`triggerElement`),B=zi(),V=zi(),H=zi();y.useEffect(()=>{if(x)return H.start(400,()=>{h.context.selectionRef.current.allowUnselectedMouseUp=!0,h.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{H.clear()};h.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},V.clear()},[x,h,V,H]);let U=Fc(w,{id:M,role:`combobox`,"aria-expanded":x,"aria-haspopup":`listbox`,"aria-controls":x?E?.id??ao(T)?.id:void 0,"aria-labelledby":N,"aria-readonly":g||void 0,"aria-required":_||void 0,tabIndex:b?-1:0,onFocus(e){I(!0),x&&h.context.alignItemWithTriggerActiveRef.current&&h.context.setOpen(!1,Q(po,e.nativeEvent)),B.start(0,()=>{h.set(`forceMount`,!0)})},onBlur(e){Z(T,e.relatedTarget)||(l(!0),I(!1),u===`onBlur`&&d.commit(C))},onMouseDown(e){if(x)return;let t=Zo(e.currentTarget);function n(e){if(!F.current)return;let t=e.target;Z(F.current,t)||Z(P.current,t)||hg(e,F.current)||h.context.setOpen(!1,Q(Do,e))}V.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},c,L),ee=d.getValidationProps(b,U);ee.role=`combobox`;let te={...f,open:x,disabled:b,value:C,readOnly:g,popupSide:j,placeholder:!A};return Jc(`button`,e,{ref:[t,F,R,z],state:te,stateAttributesMapping:zC,props:ee})}),VC=/*#__PURE__*/ y.forwardRef(function(e,t){let n=MC(),r=n.useState(`mounted`),i=n.useState(`forceMount`);return r||i?/*#__PURE__*/ (0,A.jsx)(ul,{ref:t,...e}):null}),HC=/*#__PURE__*/ y.createContext(void 0);function UC(){let e=y.useContext(HC);if(!e)throw Error(Pi(59));return e}function WC(e,t){e&&Object.assign(e.style,t)}let GC={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},KC={position:`fixed`},qC=/*#__PURE__*/ y.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m,alignItemWithTrigger:h=!0,collisionAvoidance:g=rl,style:_,...v}=e,b=MC(),x=NC(),S=b.useState(`open`),C=b.useState(`mounted`),w=b.useState(`modal`),T=b.useState(`value`),E=b.useState(`openMethod`),D=b.useState(`positionerElement`),O=b.useState(`triggerElement`),k=b.useState(`isItemEqualToValue`),j=b.useState(`transitionStatus`),M=y.useRef(null),N=y.useRef(null),[P,F]=y.useState(h),I=C&&P&&E!==`touch`;!C&&P!==h&&F(h),y.useImperativeHandle(b.context.alignItemWithTriggerActiveRef,()=>I),Wh((I||w)&&S,E===`touch`,D,O);let L=Bf({anchor:n,floatingRootContext:x,positionMethod:a,mounted:C,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??I,collisionAvoidance:g,keepMounted:!0}),R=I?`none`:L.side,z=I?KC:L.positionerStyles,B={open:S,side:R,align:L.align,anchorHidden:L.anchorHidden};X(()=>{b.set(`popupSide`,L.side)},[b,L.side]);let V=Wf(e,B,{styles:z,transitionStatus:j,props:v,refs:[t,b.useStateSetter(`positionerElement`)],hidden:!C,inert:!S}),H=y.useRef(0),U=$(e=>{if(b.context.valuesRef.current.length===0)return;let t=H.current;H.current=e.size;let n=Q(po);if(t!==0&&!b.state.multiple&&T!==null&&lS(b.context.valuesRef.current,T,k)===-1){let e=b.context.initialValueRef.current,t=e!=null&&lS(b.context.valuesRef.current,e,k)!==-1?e:null;b.context.setValue(t,n),t===null&&(b.set(`selectedIndex`,null),b.context.selectedItemTextRef.current=null)}if(t!==0&&b.state.multiple&&Array.isArray(T)){let e=T.filter(e=>lS(b.context.valuesRef.current,e,k)!==-1);e.length!==T.length&&(b.context.setValue(e,n),e.length===0&&(b.set(`selectedIndex`,null),b.context.selectedItemTextRef.current=null))}if(S&&I){b.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};WC(D,e),WC(b.context.popupRef.current,e)}}),ee=y.useMemo(()=>({...L,side:R,alignItemWithTriggerActive:I,setControlledAlignItemWithTrigger:F,scrollUpArrowRef:M,scrollDownArrowRef:N}),[L,R,I,F]);return/*#__PURE__*/ (0,A.jsx)(Ih,{elementsRef:b.context.listRef,labelsRef:b.context.labelsRef,onMapChange:U,children:/*#__PURE__*/ (0,A.jsxs)(HC.Provider,{value:ee,children:[C&&w&&/*#__PURE__*/ (0,A.jsx)(Sp,{inert:Jf(!S),cutout:O}),V]})})}),JC=`base-ui-disable-scrollbar`,YC={className:JC,getElement(e){return/*#__PURE__*/ (0,A.jsx)(`style`,{nonce:e,href:JC,precedence:`base-ui:low`,children:`.${JC}{scrollbar-width:none}.${JC}::-webkit-scrollbar{display:none}`})}},XC=/*#__PURE__*/ y.createContext(void 0),ZC={disableStyleElements:!1};function QC(){return y.useContext(XC)??ZC}let $C=`--transform-origin`,ew={...Ya,...Ba},tw=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,s=MC(),c=s.useState(`multiple`),l=s.useState(`readOnly`),u=s.useState(`highlightItemOnHover`),d=NC(),{side:f,align:p,alignItemWithTriggerActive:m,isPositioned:h,setControlledAlignItemWithTrigger:g}=UC(),_=Ch(!0)!=null,v=jf(),{nonce:b,disableStyleElements:x}=QC(),S=s.useState(`id`),C=s.useState(`open`),w=s.useState(`openMethod`),T=s.useState(`mounted`),E=s.useState(`popupProps`),D=s.useState(`transitionStatus`),O=s.useState(`triggerElement`),k=s.useState(`positionerElement`),j=s.useState(`listElement`),M=y.useRef(!1),N=y.useRef(!1),P=y.useRef({}),F=Xo(),I=$(e=>{if(!k||!s.context.popupRef.current||!N.current)return;let t=k.style.top===`0px`,n=k.style.bottom===`0px`;if(M.current||!m||!t&&!n){s.context.handleScrollArrowVisibility(e);return}let r=iw(k),i=aw(k.getBoundingClientRect().height,`y`,r),a=Zo(k),o=la(k),c=o.getComputedStyle(k),l=parseFloat(c.marginTop),u=parseFloat(c.marginBottom),d=nw(o.getComputedStyle(s.context.popupRef.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,h=rw(e),g=null,_=e=>{k.style.height=`${e}px`},v=t?h-p:p,y=Math.min(i+v,f);if(v<=1){let n=FC(v,0,f-i);n>0&&_(i+n),e.scrollTop=t?h:0,f-(i+n)<=1&&(M.current=!0),s.context.handleScrollArrowVisibility(e);return}f-y>1?g=t?1/0:0:n&&p<h&&(g=p-(v-(i+v-f)));let b=Math.ceil(y);if(b!==0&&_(b),g!=null){let t=FC(g,0,rw(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(M.current=!0),s.context.handleScrollArrowVisibility(e)});y.useImperativeHandle(s.context.scrollHandlerRef,()=>I,[I]),Ql({open:C,ref:s.context.popupRef,onComplete(){C&&s.context.onOpenChangeComplete(!0)}});let L={open:C,transitionStatus:D,side:f,align:p};X(()=>{k&&s.context.popupRef.current&&!Object.keys(P.current).length&&(P.current={top:k.style.top||`0`,left:k.style.left||`0`,right:k.style.right,height:k.style.height,bottom:k.style.bottom,minHeight:k.style.minHeight,maxHeight:k.style.maxHeight,marginTop:k.style.marginTop,marginBottom:k.style.marginBottom})},[s,k]),X(()=>{C||m||(N.current=!1,M.current=!1,WC(k,P.current))},[C,m,k]),X(()=>{let e=s.context.popupRef.current;if(!C||!O||!k||!e||m&&!h||s.state.transitionStatus===`ending`)return;if(N.current=!0,e.style.removeProperty($C),!m){F.request(()=>s.context.handleScrollArrowVisibility(j||e));return}let t=cw(e);try{let t=s.context.selectedItemTextRef.current;t?.isConnected||(t=!s.select(`hasSelectedValue`)&&s.context.firstItemTextRef.current?.isConnected?s.context.firstItemTextRef.current:null);let n=s.context.valueRef.current,r=la(k),i=r.getComputedStyle(k),a=r.getComputedStyle(e),o=Zo(O),c=iw(O),l=ow(O.getBoundingClientRect(),c),d=ow(k.getBoundingClientRect(),c),f=l.height,p=j||e,m=p.scrollHeight,h=parseFloat(a.borderBottomWidth),_=parseFloat(i.marginTop)||10,y=parseFloat(i.marginBottom)||10,b=parseFloat(i.minHeight)||100,x=nw(a),S=o.documentElement.clientHeight-_-y,C=o.documentElement.clientWidth,w=S-l.bottom+f,T,E=v===`rtl`?l.right-d.width:l.left,D=0;if(t&&n){let e=ow(n.getBoundingClientRect(),c);T=ow(t.getBoundingClientRect(),c),E=d.left+(v===`rtl`?e.right-T.right:e.left-T.left);let r=e.top-l.top+e.height/2;D=T.top-d.top+T.height/2-r}let A=w+D+y+h,N=Math.min(S,A),F=S-_-y,I=A-N,L=C-5;k.style.left=`${FC(E,5,L-d.width)}px`,k.style.height=`${N}px`,k.style.maxHeight=`none`,k.style.marginTop=`${_}px`,k.style.marginBottom=`${y}px`,e.style.height=`100%`;let R=rw(p),z=I>=R-1;z&&(N=Math.min(S,d.height)-(I-R));let B=l.top<20||l.bottom>S-20||Math.ceil(N)+1<Math.min(m,b),V=(r.visualViewport?.scale??1)!==1&&Zi;if(B||V){WC(k,P.current),g(!1);return}let H=Math.max(b,N);if(z){let e=Math.max(0,S-A);k.style.top=d.height>=F?`0`:`${e}px`,k.style.height=`${N}px`,p.scrollTop=rw(p)}else k.style.bottom=`0`,p.scrollTop=I;if(T){let t=d.top,n=d.height,r=T.top+T.height/2,i=FC(n>0?(r-t)/n*100:50,0,100);e.style.setProperty($C,`50% ${i}%`)}(H===S||N>=x)&&(M.current=!0),s.context.handleScrollArrowVisibility(p),u&&s.state.selectedIndex===null&&s.state.activeIndex===null&&s.context.listRef.current[0]!=null&&s.set(`activeIndex`,0)}finally{t()}},[s,C,k,O,m,g,F,j,u,v,h]),y.useEffect(()=>{if(!m||!k||!C)return;let e=la(k);function t(e){s.context.setOpen(!1,Q(`window-resize`,e))}return No(e,`resize`,t)},[s,m,k,C]);let R={...j?{role:`presentation`}:{role:`listbox`,"aria-multiselectable":c||void 0,"aria-readonly":l||void 0,id:`${S}-list`},onKeyDown(e){_&&yp.has(e.key)&&e.stopPropagation()},onScroll(e){j||I(e.currentTarget)},...m&&{style:j?{height:`100%`}:GC},className:!j&&m?YC.className:void 0},z=Jc(`div`,e,{ref:[t,s.context.popupRef],state:L,stateAttributesMapping:ew,props:[E,R,Uf(D),o]});return/*#__PURE__*/ (0,A.jsxs)(y.Fragment,{children:[!x&&YC.getElement(b),/*#__PURE__*/ (0,A.jsx)(Ol,{context:d,modal:!1,disabled:!T,openInteractionType:w,returnFocus:a,restoreFocus:!0,children:z})]})});function nw(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function rw(e){return IC(e.scrollHeight,e.clientHeight)}function iw(e){return Ud.getScale(e)}function aw(e,t,n){return e/n[t]}function ow(e,t){return Os({x:aw(e.x,`x`,t),y:aw(e.y,`y`,t),width:aw(e.width,`x`,t),height:aw(e.height,`y`,t)})}let sw=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function cw(e){let{style:t}=e,n={};for(let[e,r]of sw)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of sw){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}let lw=/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=MC(),s=o.useState(`multiple`),c=o.useState(`readOnly`),{alignItemWithTriggerActive:l}=UC(),u=o.useState(`hasScrollArrows`),d=o.useState(`openMethod`),f={id:`${o.useState(`id`)}-list`,role:`listbox`,"aria-multiselectable":s||void 0,"aria-readonly":c||void 0,onScroll(e){o.context.scrollHandlerRef.current?.(e.currentTarget)},...l&&{style:GC},className:u&&d!==`touch`?YC.className:void 0};return Jc(`div`,e,{ref:[t,o.useStateSetter(`listElement`)],props:[f,a]})}),uw=/*#__PURE__*/ y.createContext(void 0),dw=/*#__PURE__*/ y.memo(/*#__PURE__*/ y.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,u=y.useRef(null),d=dh({guess:!0,label:o,textRef:u}),f=MC(),{props:p,multiple:m,disabled:h,readOnly:g,isItemEqualToValue:_}=f.useState(`itemRoot`),v=h||s,b=f.useState(`isActive`,d.index),x=f.useState(`open`),S=f.useState(`isSelected`,a),C=f.useState(`isSelectedByFocus`,d.index),w=d.index,T=y.useRef(null);X(()=>{let e=f.context.valuesRef.current;return e[w]=a,()=>{delete e[w]}},[w,a,f]),X(()=>{let e=f.state.value,t=f.state.selectedIndex,n=t,r;m&&Array.isArray(e)?(n=fS(w,a,f.context.valuesRef.current,e,_,t),r=n===w,w===t&&!r&&(f.context.selectedItemTextRef.current=null)):(r=e!==void 0&&oS(a,e,_),r&&(n=w)),f.set(`selectedIndex`,n),r&&u.current&&(f.context.selectedItemTextRef.current=u.current)},[w,m,_,f,a]);let E=y.useRef(`mouse`),D=y.useRef(!1),{getButtonProps:O,buttonRef:k}=pp({disabled:v,focusableWhenDisabled:!0,native:c,composite:!0}),j={disabled:v,selected:S,highlighted:b};function M(e){if(h||g)return;let t=f.state.value;if(m){let n=Array.isArray(t)?t:[],r=S?pS(n,a,_):[...n,a];f.context.setValue(r,Q(_o,e))}else f.context.setValue(a,Q(_o,e)),f.context.setOpen(!1,Q(_o,e))}function N(){f.context.selectionRef.current.dragY=0}let P={role:`option`,"aria-selected":S,tabIndex:x&&b?0:-1,onKeyDown(e){f.set(`activeIndex`,w),e.key===` `&&f.context.typingRef.current&&e.preventDefault()},onClick(e){let t=E.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&ra(e.nativeEvent)&&(n!==void 0||b),i=t&&!r&&!D.current;D.current=!1,v||i||M(e.nativeEvent)},onPointerEnter(e){E.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=f.context.selectionRef.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){E.current=e.pointerType,D.current=!0,N()},onMouseUp(){if(N(),v||E.current===`touch`||D.current)return;let e=!f.context.selectionRef.current.allowSelectedMouseUp&&S,t=!f.context.selectionRef.current.allowUnselectedMouseUp&&!S;e||t||(D.current=!0,T.current?.click(),D.current=!1)}},F=Jc(`div`,e,{ref:[k,t,d.ref,T],state:j,props:[p,P,l,O]}),I=y.useMemo(()=>({selected:S,index:w,textRef:u,selectedByFocus:C}),[S,w,u,C]);return/*#__PURE__*/ (0,A.jsx)(uw.Provider,{value:I,children:F})}));je(),qe(),cn(),ti(Ae,Ke,sn);function fw(e){let{label:t,value:n,onChange:r,options:i,searchable:a=i.length>8,placeholder:o,searchPlaceholder:s,required:c,disabled:l,error:u,name:d,className:f}=e,p=y.useId(),m=i.find(e=>e.value===n)??null,h=t?/* @__PURE__ */ (0,A.jsx)(N_,{id:p,required:c,children:t}):null,g=/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(!m&&`is-placeholder`),children:m?m.label:o||w(`請選擇`)}),u?/* @__PURE__ */ (0,A.jsx)(F_,{inline:!0}):null,/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-down`,size:16,className:`ui-select-chev`})]}),_=p+`-err`,v=/* @__PURE__ */ (0,A.jsx)(I_,{id:_,error:u}),b=(e,t)=>/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{children:e.label}),t?/* @__PURE__ */ (0,A.jsx)(Y,{name:`check`,size:16}):null]}),x={"aria-labelledby":t?p:void 0,"aria-label":t?void 0:e[`aria-label`],"aria-invalid":u?!0:void 0,"aria-describedby":u?_:void 0},S=M(`ui-select-trigger`,u&&`is-invalid`);return a?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-select`,f),children:[h,/* @__PURE__ */ (0,A.jsxs)(IS,{items:i,value:m,onValueChange:e=>e&&r?.(e.value),itemToStringLabel:e=>e.label,isItemEqualToValue:(e,t)=>e.value===t.value,disabled:l,required:c,name:d,children:[/* @__PURE__ */ (0,A.jsx)($S,{className:S,...x,children:g}),/* @__PURE__ */ (0,A.jsx)(oC,{children:/* @__PURE__ */ (0,A.jsx)(sC,{className:`ui-select-positioner`,align:`start`,sideOffset:6,children:/* @__PURE__ */ (0,A.jsxs)(lC,{className:`ui-select-menu`,"aria-label":t||e[`aria-label`],children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-select-search`,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`magnifying-glass`,size:14}),/* @__PURE__ */ (0,A.jsx)(XS,{placeholder:s||w(`搜尋`),"aria-label":s||w(`搜尋`)})]}),/* @__PURE__ */ (0,A.jsx)(xC,{className:`ui-select-empty`,children:w(`找不到符合的選項`)}),/* @__PURE__ */ (0,A.jsx)(rC,{children:e=>/* @__PURE__ */ (0,A.jsx)(hC,{value:e,disabled:e.disabled,className:M(`ui-select-opt`,e.value===n&&`is-on`),children:b(e,e.value===n)},e.value)})]})})})]}),v]}):/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-select`,f),children:[h,/* @__PURE__ */ (0,A.jsxs)(RC,{items:i,value:n??null,onValueChange:e=>e!=null&&r?.(e),disabled:l,required:c,name:d,children:[/* @__PURE__ */ (0,A.jsx)(BC,{className:S,...x,children:g}),/* @__PURE__ */ (0,A.jsx)(VC,{children:/* @__PURE__ */ (0,A.jsx)(qC,{className:`ui-select-positioner`,alignItemWithTrigger:!1,align:`start`,sideOffset:6,children:/* @__PURE__ */ (0,A.jsx)(tw,{className:`ui-select-menu`,children:/* @__PURE__ */ (0,A.jsx)(lw,{children:i.map(e=>/* @__PURE__ */ (0,A.jsx)(dw,{value:e.value,disabled:e.disabled,className:M(`ui-select-opt`,e.value===n&&`is-on`),children:b(e,e.value===n)},e.value))})})})})]}),v]})}qe(),ti(Ke);function pw({children:e,actionLabel:t,onAction:n}){return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-toast`,role:`status`,children:[/* @__PURE__ */ (0,A.jsx)(Y,{name:`check`,className:`ui-toast-icon`}),/* @__PURE__ */ (0,A.jsx)(`span`,{children:im(e)}),t?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-toast-action`,onClick:n,children:t}):null]})}function mw({title:e,categories:t,value:n,onChange:r,toast:i,className:a}){let[o,s]=y.useState(n??t[0]?.id),c=n??o,l=t.find(e=>e.id===c)??t[0];return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-settings`,a),children:[e?/* @__PURE__ */ (0,A.jsx)(`h1`,{className:`ui-settings-title`,children:e}):null,/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-settings-body`,children:[/* @__PURE__ */ (0,A.jsx)(`nav`,{className:`ui-settings-nav`,"aria-label":w(`設定分類`),children:t.map(e=>{let t=e.id===c;return/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:M(`ui-settings-cat`,t&&`is-on`),"aria-current":t?`page`:void 0,onClick:()=>{s(e.id),r?.(e.id)},children:e.label},e.id)})}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-settings-content`,children:l?.content})]}),i?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-settings-toast`,children:/* @__PURE__ */ (0,A.jsx)(pw,{children:i})}):null]})}function hw({title:e,description:t,children:n,className:r}){return/* @__PURE__ */ (0,A.jsxs)(`section`,{className:M(`ui-settings-section`,r),children:[e?/* @__PURE__ */ (0,A.jsx)(`h2`,{className:`ui-settings-h`,children:e}):null,t?/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-settings-desc`,children:im(t)}):null,n]})}function gw({width:e=`100%`,height:t=16}){return/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-skel`,style:{width:e,height:t},"aria-hidden":`true`})}rt(),ti(nt);function _w({title:e,before:t,after:n,copyText:r,copyLabel:i,onCopy:a,onCopyError:o,refHref:s,onRef:c,isRef:l,className:u}){let[d,f]=y.useState(!1),p=y.useRef(void 0);y.useEffect(()=>()=>clearTimeout(p.current),[]);let m=()=>{let e=r??n;te(e).then(()=>{f(!0),clearTimeout(p.current),p.current=setTimeout(()=>f(!1),2e3),a?.(e)},()=>o?.())},h=(e,t)=>/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-sug-line is-`+e,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-sug-mark`,"aria-hidden":`true`,children:e===`del`?`−`:`+`}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:w(e===`del`?`原本:`:`改成:`)}),/* @__PURE__ */ (0,A.jsx)(rm,{className:`ui-sug-text`,text:t,refHref:s,onRef:c,isRef:l})]});return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-sug`,u),children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-sug-head`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-sug-title`,children:e||w(`建議修正`)}),/* @__PURE__ */ (0,A.jsx)(np,{className:M(`ui-sug-copy`,d&&`is-copied`),label:d?w(`已複製`):i||w(`複製修正`),icon:d?pi:`copy`,onClick:m})]}),t==null?null:h(`del`,t),h(`add`,n),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,"aria-live":`polite`,children:d?w(`已複製`):``})]})}function vw({items:e,value:t,onChange:n,label:r,iconOnly:i=!1,className:a}){G(i&&e.some(e=>!e.icon),`SegmentedControl`,`iconOnly 需要每一項都有 icon;沒有圖示的那一項只剩空白。補上 icon,或拿掉 iconOnly 改顯示文字。`);let o=y.useRef([]),s=Math.max(0,e.findIndex(e=>e.id===t)),[c,l]=y.useState(null),[u,d]=y.useState(!0);y.useLayoutEffect(()=>{let e=o.current[s];if(!e)return;let t=()=>l({left:e.offsetLeft,width:e.offsetWidth});t();let n=U(t);return n?.observe(e),()=>n?.disconnect()},[s,e.length]);let f=t=>{t!==s&&e[t]&&(d(t>s),n?.(e[t].id))};return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-seg`,i&&`is-icons`,a),role:`radiogroup`,"aria-label":r,children:[c?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-seg-ind`,"aria-hidden":`true`,style:{left:c.left,width:c.width,transition:hi(`left`,`width`,u)}}):null,e.map((t,n)=>{let r=/* @__PURE__ */ (0,A.jsxs)(`button`,{ref:e=>{o.current[n]=e},type:`button`,role:`radio`,"aria-checked":n===s,"aria-label":i?t.label:void 0,tabIndex:n===s?0:-1,className:M(`ui-seg-item`,n===s&&`is-selected`),onClick:()=>f(n),onKeyDown:t=>{if(W(t))return;let r=e.length,i=t.key===`ArrowRight`||t.key===`ArrowDown`?(n+1)%r:t.key===`ArrowLeft`||t.key===`ArrowUp`?(n-1+r)%r:-1;i<0||(t.preventDefault(),o.current[i]?.focus(),f(i))},children:[t.icon?/* @__PURE__ */ (0,A.jsx)(fi,{icon:t.icon,size:16,filled:i&&n===s}):null,i?null:/* @__PURE__ */ (0,A.jsx)(`span`,{children:t.label})]},t.id);return i?/* @__PURE__ */ (0,A.jsx)(Zf,{label:t.label,describe:!1,side:`bottom`,children:r},t.id):r})]})}qt(),Hr(),ti(Kt,Vr);function yw({children:e,variant:t=`plain`,className:n}){return/* @__PURE__ */ (0,A.jsxs)(`span`,{className:M(`ui-tag`,t!==`plain`&&`is-`+t,n),children:[t===`forecast`?/* @__PURE__ */ (0,A.jsx)(Y,{name:`trend-up`,size:16}):t===`demo`?/* @__PURE__ */ (0,A.jsx)(Y,{name:`info`,size:16}):null,e]})}function bw({label:e,hint:t,error:n,value:r,onChange:i,maxLength:a=200,className:o,id:s,required:c,...l}){let u=y.useId(),d=s||u,f=n?d+`-err`:t?d+`-hint`:void 0,p=y.useRef(null);return y.useLayoutEffect(()=>{let e=p.current;e&&(e.style.height=`auto`,e.style.height=Math.min(e.scrollHeight+2,230)+`px`)},[r]),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-field`,n&&`has-error`,o),children:[e?/* @__PURE__ */ (0,A.jsx)(N_,{htmlFor:d,required:c,children:e}):null,/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-field-box`,children:[/* @__PURE__ */ (0,A.jsx)(`textarea`,{rows:3,...l,ref:p,id:d,className:`ui-input ui-textarea`,maxLength:a,value:r||``,"aria-required":c||void 0,"aria-describedby":[l[`aria-describedby`],f].filter(Boolean).join(` `)||void 0,"aria-invalid":n?!0:void 0,onChange:e=>i(e.target.value)}),n?/* @__PURE__ */ (0,A.jsx)(F_,{}):null]}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-field-foot`,children:[n?/* @__PURE__ */ (0,A.jsx)(`span`,{id:f,className:`ui-field-error`,role:`alert`,children:im(n)},n):/* @__PURE__ */ (0,A.jsx)(`span`,{id:f,className:`ui-field-hint`,children:im(t||``)}),/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-count`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-seen`,"data-text":p_.fraction((r||``).length,a)})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:p_.fractionLabel((r||``).length,a,w(`字`))})]})]})]})}let xw=[{id:`auto`,label:`自動`},{id:`light`,label:`淺色`},{id:`dark`,label:`深色`}];function Sw({value:e,onChange:t,label:n,className:r}){let[i,a]=y.useState(()=>e??vm()),o=e??i,s=y.useRef([]),c=e=>{a(e),t?t(e):xm(e)},l=Math.max(0,xw.findIndex(e=>e.id===o));return/* @__PURE__ */ (0,A.jsx)(`div`,{role:`radiogroup`,"aria-label":n||w(`主題`),className:M(`ui-themepick`,r),children:xw.map((e,t)=>/* @__PURE__ */ (0,A.jsxs)(`button`,{ref:e=>{s.current[t]=e},type:`button`,role:`radio`,"aria-checked":o===e.id,tabIndex:t===l?0:-1,className:M(`ui-themepick-opt`,o===e.id&&`is-on`),onClick:()=>c(e.id),onKeyDown:e=>{if(W(e))return;let n=xw.length,r=e.key===`ArrowRight`||e.key===`ArrowDown`?(t+1)%n:e.key===`ArrowLeft`||e.key===`ArrowUp`?(t-1+n)%n:-1;r<0||(e.preventDefault(),s.current[r]?.focus(),c(xw[r].id))},children:[/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-themepick-mini is-`+e.id,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{}),/* @__PURE__ */ (0,A.jsx)(`span`,{})]}),w(e.label)]},e.id))})}let Cw=`ui-tour:`;function ww(e){let[t,n]=y.useState(()=>!!I(Cw+e)),[r,i]=y.useState(!1),a=y.useRef(!1);y.useLayoutEffect(()=>{!I(Cw+e)&&!a.current&&i(!0)},[e]);let o=()=>{I(Cw+e,`1`),n(!0)};return{open:r,start:()=>i(!0),close:()=>{o(),i(!1)},seen:t,hint:(e,n)=>{if(a.current=!0,!(t||r))return{text:e,action:n,onAction:()=>i(!0),onDismiss:o}}}}function Tw(e){if(!e)return null;if(typeof e==`string`){let t=/^[\w-]+$/.test(e)&&!/^(html|body|main|nav|header|footer|section|aside)$/.test(e)?`[data-tour="${e}"]`:e;return Array.from(document.querySelectorAll(t)).find(e=>e.getClientRects().length>0)??null}return e instanceof Element?e:e.current}function Ew(){return parseFloat(getComputedStyle(document.documentElement).getPropertyValue(`--space-3`))||12}let Dw=()=>typeof window<`u`&&window.innerWidth<600;function Ow(e){let t=typeof window>`u`?0:window.innerHeight;if(!Dw())return{top:0,bottom:t};let n=0,r=t,i=document.querySelector(`.ui-shell-top`),a=document.querySelector(`.ui-tabbar`);if(i&&!(e&&i.contains(e))){let e=i.getBoundingClientRect();e.height&&e.bottom>0&&e.bottom<t/2&&(n=e.bottom)}if(a&&!(e&&a.contains(e))){let e=a.getBoundingClientRect();e.height&&e.top>t/2&&e.top<t&&(r=e.top)}return{top:n,bottom:r}}let kw=(e,t)=>Math.max(0,Math.min(e.left+e.width,t.left+t.width)-Math.max(e.left,t.left))*Math.max(0,Math.min(e.top+e.height,t.top+t.height)-Math.max(e.top,t.top));function Aw(e,t,n,r,i=320,a=[]){let o=typeof document>`u`?12:Ew(),s=typeof window>`u`?0:window.innerWidth,c=r?.bottom??(typeof window>`u`?0:window.innerHeight),l=r?.top??0;if(!e)return{mode:`center`,box:{left:(s-i)/2,top:Math.max(l+o,(l+c)/2-t/2),width:i,height:t},fits:!0};let u=e=>Math.max(o,Math.min(s-o-i,e)),d=e=>Math.max(l+o,Math.min(c-o-t,e)),f=e.left+e.width/2-i/2,p=e.top+e.height/2-t/2,m={bottom:{left:f,top:e.top+e.height+12},top:{left:f,top:e.top-12-t},right:{left:e.left+e.width+12,top:p},left:{left:e.left-12-i,top:p}},h=(n===`top`?[`top`,`bottom`,`right`,`left`]:[`bottom`,`top`,`right`,`left`]).map(n=>{let r=m[n],o={left:u(r.left),top:d(r.top),width:i,height:t},s=n===`bottom`||n===`top`?o.top===r.top:o.left===r.left,c=kw(o,e),l=a.reduce((e,t)=>e+kw(o,t),0);return{mode:n,box:o,fits:s&&!c&&!l,onTarget:c,onKept:l}}),g=h.find(e=>e.fits)??[...h].sort((e,t)=>e.onTarget-t.onTarget||e.onKept-t.onKept)[0];return{mode:g.mode,box:g.box,fits:g.fits}}function jw({open:e,steps:t,onClose:n,skippable:r=!0,step:i,onStepChange:a}){let[o,s]=y.useState(0),c=Math.max(0,Math.min(t.length-1,i??o)),l=t[c],[u,d]=y.useState(null),[f,p]=y.useState([]),m=y.useRef(null),[h,g]=y.useState(0),[_,v]=y.useState(320),[b,x]=y.useState(e);e!==b&&(x(e),e&&i==null&&s(0));let S=e=>{a?.(e),i??s(e)},C=e=>n?.(e);Wm(e);let T=y.useRef(-1);y.useEffect(()=>{!e||!l?T.current=-1:(T.current!==-1&&T.current!==c&&bi(w(`第 {a} 步,共 {b} 步`,{a:c+1,b:t.length})+w(`。`)+l.title+w(`。`)+l.text.replace(/`/g,``)),T.current=c)},[e,c,l,t.length]);let E=y.useRef(null),D=()=>Array.from(E.current?.querySelectorAll(`button:not(:disabled), a[href], input:not(:disabled), [tabindex]:not([tabindex="-1"])`)??[]).filter(e=>e.getClientRects().length>0),O=e=>{if(e.key!==`Tab`||e.altKey||e.ctrlKey||e.metaKey)return;let t=D();if(!t.length)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[n<0?0:(n+(e.shiftKey?-1:1)+t.length)%t.length].focus()};y.useEffect(()=>{if(!e)return;let t=e=>{let t=E.current;t&&e.target instanceof Node&&!t.contains(e.target)&&(m.current??D()[0])?.focus()};return document.addEventListener(`focusin`,t),()=>document.removeEventListener(`focusin`,t)},[e]);let k=l?.target,j=l?.padding??6,P=l?.keepVisible==null?[]:Array.isArray(l.keepVisible)?l.keepVisible:[l.keepVisible],F=P.map(e=>typeof e==`string`?e:`#`).join(`|`),I=y.useRef(P);y.useLayoutEffect(()=>{I.current=P});let L=!!l;y.useEffect(()=>{if(!e||!L)return;let t=Tw(k),n=(t?.getBoundingClientRect().height??0)>window.innerHeight;if(G(t&&t.getBoundingClientRect().height>window.innerHeight*.7,`Tour`,`第 ${c+1} 步的目標「${k}」比視窗的 70% 高,說明卡只能蓋住它的一部分。請把 data-tour 放在較小的元素上,例如要說明的那張卡片或那一列,而不是整頁。`),t instanceof HTMLElement&&Dw()){let e=t.style.scrollMarginTop;t.style.scrollMarginTop=Ow(t).top+Ew()+j+`px`,t.scrollIntoView?.({block:`start`,behavior:`auto`}),t.style.scrollMarginTop=e}else t?.scrollIntoView?.({block:n?`start`:`center`,behavior:`auto`});let r=0,i=``,a=()=>{t?.isConnected||(t=Tw(k));let e=t?.getBoundingClientRect(),n=null;if(e&&e.width){let t=Math.max(3,e.left-j),r=Math.max(3,e.top-j);n={left:t,top:r,width:Math.max(0,Math.min(window.innerWidth-3,e.right+j)-t),height:Math.max(0,Math.min(window.innerHeight-3,e.bottom+j)-r)}}let o=[];for(let e of I.current){let t=Tw(e)?.getBoundingClientRect();t&&t.width&&o.push({left:t.left,top:t.top,width:t.width,height:t.height})}let s=JSON.stringify([n,o]);s!==i&&(i=s,d(n),p(o)),r=requestAnimationFrame(a)};return a(),()=>cancelAnimationFrame(r)},[e,L,c,k,j,F]);let R=y.useRef(null),z=y.useCallback(e=>{if(E.current=e,R.current?.disconnect(),R.current=null,!e)return;let t=()=>{g(e.offsetHeight),v(e.offsetWidth)};t(),R.current=U(t),R.current?.observe(e)},[]),B=h>0;y.useEffect(()=>{if(!e||!L||!B)return;let t=Tw(k);if(!(t instanceof HTMLElement))return;let n=Ow(t),r=Ew(),i=t.getBoundingClientRect(),a=i.top-j,o=i.bottom+j;if(Aw({left:i.left-j,top:a,width:i.width+2*j,height:o-a},h,l?.side??`bottom`,n,_,f).fits)return;let s=o-a+12+h+2*r<=n.bottom-n.top?n.top+r+j:n.top+r+h+12+j,c=t.parentElement;for(;c&&!(/(auto|scroll)/.test(getComputedStyle(c).overflowY)&&c.scrollHeight>c.clientHeight);)c=c.parentElement;let u=i.top-s;c?c.scrollBy({top:u,behavior:`auto`}):window.scrollBy({top:u,behavior:`auto`})},[e,L,c,k,j,B,h]);let V=e&&l?Ow(Tw(l.target)):void 0,H=Aw(u,h,l?.side??`bottom`,V,_,f),ee=H.box.left,te=H.box.top,ne=y.useMemo(()=>({getBoundingClientRect:()=>new DOMRect(ee,te,0,0)}),[ee,te]);if(!e||!l)return null;let W=c===t.length-1;return/* @__PURE__ */ (0,A.jsx)(sv,{open:!0,modal:!0,onOpenChange:(e,t)=>{t.reason===`escape-key`&&r&&C(`skip`)},children:/* @__PURE__ */ (0,A.jsxs)(pv,{children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tour-layer`,children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-tour-block`,!u&&`is-dim`)}),u?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-tour-spot`,"aria-hidden":`true`,style:u}):null]}),/* @__PURE__ */ (0,A.jsx)(gv,{className:`ui-float ui-tour-float`,anchor:ne,side:`bottom`,align:`start`,sideOffset:0,collisionAvoidance:{side:`none`,align:`none`,fallbackAxisSide:`none`},children:/* @__PURE__ */ (0,A.jsxs)(bv,{ref:z,className:`ui-tour-card`,"data-placement":H.mode,initialFocus:m,onKeyDown:O,children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tour-body`,children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tour-count`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{"aria-hidden":`true`,children:N(w(`{n} / {total}`,{n:``,total:``}),[String(c+1),String(t.length)])}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,children:w(`第 {a} 步,共 {b} 步`,{a:c+1,b:t.length})})]}),/* @__PURE__ */ (0,A.jsx)(Sv,{className:`ui-tour-title`,children:l.title}),/* @__PURE__ */ (0,A.jsx)(rm,{as:`div`,className:`ui-tour-text`,text:l.text})]}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tour-actions`,children:[r&&!W?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn is-muted`,onClick:()=>C(`skip`),children:w(`略過`)}):null,/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tour-gap`}),c>0?/* @__PURE__ */ (0,A.jsx)(Xp,{onClick:()=>S(c-1),children:w(`上一步`)}):null,/* @__PURE__ */ (0,A.jsx)(Xp,{ref:m,variant:`primary`,onClick:()=>W?C(`done`):S(c+1),children:w(W?`完成`:`下一步`)})]})]},c)})]})})}let Mw={pdf:`pdf`,mp4:`video`,mov:`video`,mkv:`video`,webm:`video`,avi:`video`,mp3:`audio`,wav:`audio`,m4a:`audio`,ppt:`slides`,pptx:`slides`,key:`slides`,odp:`slides`,doc:`doc`,docx:`doc`,txt:`doc`,md:`doc`,odt:`doc`,xls:`sheet`,xlsx:`sheet`,csv:`sheet`,ods:`sheet`,zip:`archive`,rar:`archive`,tar:`archive`,gz:`archive`,"7z":`archive`,png:`image`,jpg:`image`,jpeg:`image`,gif:`image`,svg:`image`,webp:`image`,py:`code`,js:`code`,ts:`code`,c:`code`,cpp:`code`,java:`code`,ipynb:`code`,sh:`code`};function Nw(e){let t=/\.([a-z0-9]+)$/i.exec(e.name||``);return String(e.ext||(t?t[1]:``)).toLowerCase()}let Pw=(e,t)=>e.flatMap(e=>{let n=t(e);return n?[e,...Pw(n,t)]:e.hasChildren?[e]:[]}),Fw=e=>e==null?null:e instanceof Date?e:new Date(e);function Iw(e){let t=Fw(e.date);for(let n of e.children??[]){let e=Iw(n);e&&(!t||e>t)&&(t=e)}return t}function Lw(e,t,n=!1){return n?[...e]:e.map((e,t)=>[e,t]).sort(([e,n],[r,i])=>{let a=!!e.children;if(a!==!!r.children)return a?-1:1;if(!t)return n-i;if(t===`name`)return String(e.name).localeCompare(String(r.name),S.locale,{numeric:!0})||n-i;let o=+(Iw(e)||0),s=+(Iw(r)||0);return(t===`oldest`?o-s:s-o)||n-i}).map(([e])=>e)}function Rw(e,t,n){for(let r of t){if(r.id===e)return r;let t=n(r),i=t&&Rw(e,t,n);if(i)return i}return null}function zw(e,t,n,r=[]){for(let i of t){let t=[...r,i];if(i.id===e)return t;let a=n(i),o=a&&zw(e,a,n,t);if(o)return o}return null}Fe(),pt(),Dt(),kt(),ti(Pe,ft,Et,Ot);let Bw=e=>e;function Vw({guides:e}){return/* @__PURE__ */ (0,A.jsx)(A.Fragment,{children:e.map(e=>/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-tree-guide`,e>=3&&`is-deep`),"aria-hidden":`true`,style:Bw({"--g":e})},e))})}function Hw(e){let{items:t}=e,n=e.expand===`single`,r=e.kind===`plain`,i=r&&e.density===`compact`;G(e.density===`compact`&&!r,`TreeList`,`density="compact" works with kind="plain" only: the files kind needs room for date and size.`);let a=e.sort===void 0?!r&&`newest`:e.sort,o=!!e.selectable&&!r;G(r&&e.selectable,`TreeList`,`selectable works with kind="files" only; for plain trees use selectedId and onSelect.`);let[s,c]=y.useState(()=>Object.fromEntries((e.defaultOpen??[]).map(e=>[e,!0]))),l=e.open?Object.fromEntries(e.open.map(e=>[e,!0])):s,[u,d]=y.useState({}),f=e=>{let t=u[e.id];return e.children??(t?.status===`done`?t.children:null)},p=e=>{let t=f(e);return t?t.length>0:!!e.hasChildren},m=t=>{let n=e.loadChildren;n&&!f(t)&&u[t.id]?.status!==`loading`&&(d(e=>({...e,[t.id]:{status:`loading`}})),Promise.resolve().then(()=>n(t)).then(e=>d(n=>({...n,[t.id]:{status:`done`,children:e||[]}})),e=>d(n=>({...n,[t.id]:{status:`error`,error:e instanceof Error?e.message:String(e??``)}}))))},h=e.open?.join(`\0`);y.useEffect(()=>{for(let e of Object.keys(l)){let n=l[e]?Rw(e,t,f):null;n&&m(n)}},[h]);let[g,_]=y.useState({});y.useEffect(()=>{if(!Object.keys(g).length)return;let e=setTimeout(()=>_({}),400);return()=>clearTimeout(e)},[g]);let[v,b]=y.useState([]),x=e.selected??v,S=t=>{e.selected||b(t),e.onSelectChange?.(t)},C=y.useId().replace(/:/g,``),[T,E]=y.useState(null),D=y.useRef({}),O=y.useRef(null);y.useEffect(()=>{O.current&&=(D.current[O.current]?.focus(),null)});let k=new Set(x),N=e=>{let t=f(e);return t?t.flatMap(N):e.hasChildren?[]:[e]},P=t.flatMap(N),F=r=>{let i={...l},a=!i[r.id];if(n&&a){let e=zw(r.id,t,f),n=(e&&e.length>1?f(e[e.length-2]):t)??[];for(let e of n)e.id!==r.id&&(i[e.id]=!1)}i[r.id]=a,_(a&&!L()?{[r.id]:!0}:{}),a&&m(r),e.onToggle?.(r,a,Object.keys(i).filter(e=>i[e])),e.open||c(i);let o=a?f(r):null;bi(a?o?w(`已展開,{n} 個子項目`,{n:o.length}):w(`已展開`):w(`已收合`))},I=e=>{let t=N(e),n=t.filter(e=>k.has(e.id)).length;return n===0?!1:n===t.length||`mixed`},R=e=>{let t=I(e)!==!0,n=new Set(k);for(let r of N(e))t?n.add(r.id):n.delete(r.id);S(P.filter(e=>n.has(e.id)).map(e=>e.id))},z=t=>e.onOpen?e.onOpen(t):e.onDownload?.([t]),B=[],V=(t,n,i,o)=>{let s=Lw(t,a,r&&!a);s.forEach((t,a)=>{let c=r?p(t):!!(t.children||t.hasChildren),d=c&&!!l[t.id];if(B.push({n:t,depth:n,guides:i,fresh:o,isF:c,open:d,pos:a+1,size:s.length}),!d)return;let m=f(t),h=u[t.id],_=[...i,n];m?V(m,n+1,_,o||!!g[t.id]):h?.status===`error`?B.push({x:`error`,n:t,depth:n+1,guides:_,error:h.error}):e.loadChildren&&B.push({x:`loading`,n:t,depth:n+1,guides:_})})};V(t,0,[],!1);let H=B.filter(e=>!e.x),U=Math.max(0,H.findIndex(e=>e.n.id===T)),ee=e=>{H[e]&&(O.current=H[e].n.id,E(H[e].n.id))},te=y.useRef(null);y.useLayoutEffect(()=>{for(let e of te.current?.querySelectorAll(`[role="treeitem"] :is(a[href], button, input, select, textarea, [tabindex])`)??[])e.tabIndex>=0&&e.getAttribute(`role`)!==`treeitem`&&(e.tabIndex=-1)});let ie=e=>[...e.querySelectorAll(`a[href], button, input, select, textarea, [tabindex]`)].filter(t=>t.closest(`[role="treeitem"]`)===e&&t.getAttribute(`role`)!==`treeitem`&&!t.closest(`[aria-hidden="true"]`)&&!t.matches(`:disabled`)),K=t=>{if(!H.length||W(t))return;let n=t.target,i=n.closest(`[role="treeitem"]`);if(i&&i!==n){let e=ie(i),r=e.indexOf(n);if(t.key===`ArrowRight`&&r<e.length-1)e[r+1].focus();else if(t.key===`ArrowLeft`&&r>0)e[r-1].focus();else if(t.key===`ArrowLeft`||t.key===`Escape`)i.focus();else if(t.key===`ArrowDown`||t.key===`ArrowUp`)ee(U+(t.key===`ArrowDown`?1:-1));else return;t.preventDefault();return}if(n.getAttribute(`role`)!==`treeitem`)return;let a=H[U],s=t.key;if([`ArrowDown`,`ArrowUp`,`Home`,`End`,`ArrowRight`,`ArrowLeft`,`Enter`].includes(s)||s===` `&&o){if(t.preventDefault(),s===`ArrowDown`)ee(U+1);else if(s===`ArrowUp`)ee(U-1);else if(s===`Home`)ee(0);else if(s===`End`)ee(H.length-1);else if(s===`ArrowRight`){let e=ie(n);a.isF&&!a.open?F(a.n):e.length?e[0].focus():a.isF&&ee(U+1)}else if(s===`ArrowLeft`){if(a.isF&&a.open)F(a.n);else for(let e=U-1;e>=0;e--)if(H[e].depth<a.depth){ee(e);break}}else if(s===`Enter`){if(r){let t=e.selectedId!=null&&e.selectedId===a.n.id;e.onSelect?.(a.n),a.isF&&!t&&F(a.n)}else a.isF?F(a.n):z(a.n)}else R(a.n)}},q=(e,t)=>({ref:t=>{D.current[e.n.id]=t},role:`treeitem`,tabIndex:t===U?0:-1,"aria-level":e.depth+1,"aria-posinset":e.pos,"aria-setsize":e.size,"aria-expanded":e.isF?e.open:void 0,"aria-owns":e.isF&&e.open?`${C}-g-${j(e.n.id)}`:void 0,style:Bw({"--d":e.depth}),onFocus:()=>T!==e.n.id&&E(e.n.id)}),ae=(t,n)=>{let{n:r,isF:a}=t,o=e.selectedId!=null&&e.selectedId===r.id,s=r.meta??(r.path?p_.path(r.path):``);return/* @__PURE__ */ (0,A.jsxs)(`div`,{...q(t,n),"aria-label":r.ariaLabel??[r.name,...(r.tags??[]).map(re),r.meta,r.path,r.mark?.label].filter(Boolean).join(w(`,`)),"aria-selected":e.onSelect?o:void 0,className:M(`ui-tree-row`,`is-plain`,o&&`is-current`,r.muted&&`is-muted`,t.fresh&&`ui-tree-in`),onClick:()=>{T!==r.id&&E(r.id),e.onSelect?.(r),a&&!o&&F(r)},children:[/* @__PURE__ */ (0,A.jsx)(Vw,{guides:t.guides}),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,tabIndex:-1,className:M(`ui-tree-caret`,`ui-tree-caretbtn`,t.open&&`is-open`,!a&&`is-leaf`),"aria-hidden":`true`,onClick:e=>{e.stopPropagation(),a&&F(r)},children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-right`,size:i?14:16})}),r.icon?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-picon`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(fi,{icon:r.icon,size:i?16:20})}):null,/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tree-main`,children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tree-name`,children:[t.depth>3?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-depth`,"aria-hidden":`true`,title:w(`第 {n} 層`,{n:t.depth+1}),children:`L`+(t.depth+1)}):null,/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-label is-one`,children:r.name}),(r.tags??[]).map((e,t)=>/* @__PURE__ */ (0,A.jsx)(yw,{children:e},t))]}),s?/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-tree-pmeta`,r.meta==null&&`is-path`),children:r.meta==null?s:ne(s,/(\d[\d,.]*)/)}):null]}),r.mark?/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-tree-mark`,`is-`+(r.mark.tone??`warning`)),"aria-hidden":`true`,title:r.mark.label}):null,e.rowActions?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-act`,onClick:e=>e.stopPropagation(),children:e.rowActions(r)}):null]},r.id)},oe=e=>/* @__PURE__ */ (0,A.jsxs)(`div`,{className:M(`ui-tree-row is-plain is-extra`,e.x===`error`&&`is-error`),style:Bw({"--d":e.depth}),role:`none`,children:[/* @__PURE__ */ (0,A.jsx)(Vw,{guides:e.guides}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-caret is-leaf`,"aria-hidden":`true`}),e.x===`loading`?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-tree-main`,children:/* @__PURE__ */ (0,A.jsx)(gw,{width:`55%`,height:14})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-visually-hidden`,role:`status`,children:w(`載入中`)})]}):/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tree-main`,role:`alert`,children:[w(`無法載入 {name} 的子項目`,{name:e.n.name}),e.error?w(`:`)+e.error:``,w(`。`).trim()]}),/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,className:`ui-link-btn`,onClick:()=>{d(({[e.n.id]:t,...n})=>n),setTimeout(()=>m(e.n),0)},children:w(`重試`)})]})]},`${e.n.id}:${e.x}`),se=(t,n)=>{let{n:r,isF:i}=t,a=o?I(r):!1,s=i?``:Nw(r),c=Mw[s]||`other`,l=i?N(r):[],u=i?Iw(r):Fw(r.date),d=u?p_.relative(u):``,f=i?``:c_(r.size),p=l.filter(e=>e.unseen).length,m=!i&&!!r.unseen,h=(i?[l.length?w(`{n} 個檔案`,{n:l.length}):``,d]:[d,f]).filter(Boolean);return/* @__PURE__ */ (0,A.jsxs)(`div`,{...q(t,n),"aria-label":r.ariaLabel,"aria-selected":o?a===!0:void 0,className:M(`ui-tree-row`,i&&`is-folder`,a===!0&&`is-selected`,t.fresh&&`ui-tree-in`),onClick:()=>{E(r.id),i?F(r):z(r)},children:[/* @__PURE__ */ (0,A.jsx)(Vw,{guides:t.guides}),o?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-sel`,children:/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,role:`checkbox`,tabIndex:-1,"aria-checked":a,"aria-label":w(`選取 {name}`,{name:r.name}),className:M(`ui-check`,a&&`is-on`),onClick:e=>{e.stopPropagation(),R(r)},children:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-check-box`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(P_,{v:a})})})}):null,i?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-tree-caret`,t.open&&`is-open`),"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-right`,size:16})}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-ficon`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(Y,{name:t.open?`folder-open`:`folder`,size:24})})]}):/* @__PURE__ */ (0,A.jsxs)(`span`,{className:M(`ui-tree-doc`,`is-`+c),"aria-hidden":`true`,children:[/* @__PURE__ */ (0,A.jsxs)(`svg`,{width:30,height:36,viewBox:`0 0 30 36`,children:[/* @__PURE__ */ (0,A.jsx)(`path`,{d:`M5 1.5h15l7.5 7.5v25.5H5z`}),/* @__PURE__ */ (0,A.jsx)(`path`,{d:`M20 1.5V9h7.5`,fill:`none`})]}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-ext`,children:(s||`?`).slice(0,4).toUpperCase()})]}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tree-main`,children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tree-name`,children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-label`,children:r.name}),p?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-newcount`,children:w(`{n} 個新`,{n:p})}):null,i&&l.length?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-count ui-tree-mc`,children:w(`{n} 個檔案`,{n:l.length})}):null]}),h.length?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-tree-meta ui-tree-mb`,children:h.map((e,t)=>/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(!i&&e===d&&m&&`is-new`),children:(t?`· `:``)+e},t))}):null]}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-tree-col`,`ui-tree-date`,`ui-tree-mc`,m&&`is-new`),children:d}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-col ui-tree-size ui-tree-mc`,children:f}),e.onDownload?i?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-actsp`,"aria-hidden":`true`}):/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-act`,children:/* @__PURE__ */ (0,A.jsx)(np,{label:w(`下載 {name}`,{name:r.name}),icon:`download-simple`,tabIndex:-1,onClick:t=>{t.stopPropagation(),e.onDownload?.([r])}})}):null]},r.id)},ce=Pw(t,f),le=ce.some(e=>!l[e.id]),J=P.filter(e=>k.has(e.id)),ue=J.reduce((e,t)=>e+(t.size||0),0),de=!n&&ce.length>0&&(!r||!!e.toggleAll)&&(!e.open||!!e.onToggleAll);G(e.open&&(!r||e.toggleAll)&&!n&&!e.onToggleAll,`TreeList`,`with controlled open ids, 「全部展開」 needs onToggleAll to report the new ids; it is hidden until you pass it.`);let fe=o&&J.length?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tree-head ui-tree-bulk`,children:[/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-tree-bulk-count`,children:[w(`已選 {n} 個檔案`,{n:J.length}),ue?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-tree-bulk-size`,children:w(`共 {size}`,{size:c_(ue)})}):null]}),/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-tree-head-actions`,children:[/* @__PURE__ */ (0,A.jsx)(Xp,{onClick:()=>S([]),children:w(`清除選取`)}),e.onDownload?/* @__PURE__ */ (0,A.jsx)(Xp,{variant:`primary`,icon:`download-simple`,onClick:()=>{e.onDownload?.(J),S([])},children:w(`下載`)}):null,e.bulkActions?.(J,()=>S([]))]})]}):e.title||e.actions||de?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tree-head`,children:[e.title?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-tree-titles`,children:[/* @__PURE__ */ (0,A.jsx)(`h2`,{className:`ui-tree-title`,children:e.title}),e.subtitle?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-tree-subtitle`,children:e.subtitle}):null]}):/* @__PURE__ */ (0,A.jsx)(`span`,{}),/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-tree-head-actions`,children:[de?/* @__PURE__ */ (0,A.jsx)(Xp,{onClick:()=>{let t=Object.fromEntries(ce.map(e=>[e.id,le]));_(le&&!L()?Object.fromEntries(ce.filter(e=>!l[e.id]).map(e=>[e.id,!0])):{}),e.open?e.onToggleAll?.(le,le?[.../* @__PURE__ */ new Set([...e.open,...ce.map(e=>e.id)])]:[]):c(t)},children:w(le?`全部展開`:`全部收合`)}):null,e.actions??null]})]}):null,pe=e=>e.x?oe(e):r?ae(e,H.indexOf(e)):se(e,H.indexOf(e)),me=(e,t)=>{let n=[],r=e;for(;r<B.length&&B[r].depth>=t;){let e=B[r];if(n.push(pe(e)),r++,!e.x&&e.open&&r<B.length&&B[r].depth>t){let[i,a]=me(r,t+1);n.push(/* @__PURE__ */ (0,A.jsx)(`div`,{id:`${C}-g-${j(e.n.id)}`,role:`group`,className:`ui-tree-group`,children:i},`g-`+e.n.id)),r=a}}return[n,r]};return/* @__PURE__ */ (0,A.jsxs)(`section`,{className:M(`ui-tree`,r&&`is-plain`,i&&`is-compact`,o&&`is-selectable`,J.length&&`has-sel`,e.bare&&`is-bare`,e.height!=null&&`has-height`,e.className),"aria-label":e.title?void 0:e.label,style:e.height==null?void 0:{height:typeof e.height==`number`?e.height+`px`:e.height},children:[fe,H.length?/* @__PURE__ */ (0,A.jsx)(`div`,{role:`tree`,"aria-label":e.label||(typeof e.title==`string`?e.title:void 0),"aria-multiselectable":o||void 0,className:`ui-tree-list`,ref:te,onKeyDown:K,children:me(0,0)[0]}):/* @__PURE__ */ (0,A.jsx)(`p`,{className:`ui-tree-empty`,children:e.emptyText||w(r?`沒有項目`:`這裡還沒有檔案`)})]})}ai(Gr);let Uw={close:`x`,edit:`pencil-simple`,more:`dots-three`,spinner:`circle-notch`,alert:`warning-circle`,warn:`warning`,chevronRight:`caret-right`,chevronDown:`caret-down`,panelClose:`sidebar-simple`,panelOpen:`sidebar-simple`,filter:`funnel`,refresh:`arrows-clockwise`},Ww=Object.fromEntries(Gr.map(e=>[e.n,e.r])),Gw=Object.freeze({...Object.fromEntries(Object.entries(Uw).map(([e,t])=>[e,Ww[t]])),...Ww,...Object.fromEntries(Object.entries(Kr).map(([e,t])=>[e,Ww[t]]))});je(),Ne(),Fe(),ti(Ae,Me,Pe);let Kw=y.createContext(null);function qw(){let e=y.useContext(Kw);if(!e)throw Error(`useWorkbench() works inside <Workbench>.`);return e}let Jw={explorer:[180,480],side:[240,560],panel:[120,1/0]},Yw={explorer:260,side:320,panel:220},Xw={explorer:[`<rect x="40" y="56" width="64" height="144" rx="6"/>`,`<path d="M100 44v168" stroke="currentColor" stroke-width="16"/>`],side:[`<rect x="152" y="56" width="64" height="144" rx="6"/>`,`<path d="M156 44v168" stroke="currentColor" stroke-width="16"/>`],panel:[`<rect x="40" y="136" width="176" height="64" rx="6"/>`,`<path d="M28 140h200" stroke="currentColor" stroke-width="16"/>`]},Zw=(e,t)=>`<rect x="24" y="40" width="208" height="176" rx="20" fill="none" stroke="currentColor" stroke-width="16"/>`+Xw[e][+!t];function Qw(e,t){let n=e.map(e=>e.id),r=(t?.side??[]).filter(e=>n.includes(e)),i=(t?.panel??[]).filter(e=>n.includes(e)&&!r.includes(e));for(let e of n)!r.includes(e)&&!i.includes(e)&&i.push(e);return{side:r,panel:i,active:{side:r[0],panel:i[0]},open:{explorer:!0,side:!0,panel:!0,...t?.open},size:{...Yw,...t?.size}}}function $w(e,t){try{let n=I(e);if(!n)return t;let r=JSON.parse(n),i=[...t.side,...t.panel],a=(r.side??[]).filter(e=>i.includes(e)),o=(r.panel??[]).filter(e=>i.includes(e)&&!a.includes(e));for(let e of t.side)!a.includes(e)&&!o.includes(e)&&a.push(e);for(let e of t.panel)!a.includes(e)&&!o.includes(e)&&o.push(e);return{side:a,panel:o,active:{...t.active,...r.active},open:{...t.open,...r.open},size:{...t.size,...r.size}}}catch{return t}}let eT=(e,t,n)=>Math.max(t,Math.min(n,Math.round(e))),tT=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName));function nT(e){let t=y.useRef(null),[n,r]=y.useState(!1),i=t=>e.vertical?t.clientX:t.clientY;return/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-wb-split`,e.vertical?`is-v`:`is-h`,n&&`is-on`),role:`separator`,"aria-orientation":e.vertical?`vertical`:`horizontal`,"aria-label":e.label,"aria-valuenow":e.value,"aria-valuemin":e.min,"aria-valuemax":e.max,tabIndex:0,style:e.style,onPointerDown:n=>{n.currentTarget.setPointerCapture?.(n.pointerId),t.current={at:i(n),v:e.value},r(!0),e.onDrag(!0)},onPointerMove:n=>{let r=t.current;r&&e.onChange(eT(r.v+(i(n)-r.at)*e.grow,e.min,e.max))},onPointerUp:()=>{t.current=null,r(!1),e.onDrag(!1)},onPointerCancel:()=>{t.current=null,r(!1),e.onDrag(!1)},onDoubleClick:e.onReset,onKeyDown:t=>{let n=t.shiftKey?64:16,r=e.vertical?e.grow>0?`ArrowRight`:`ArrowLeft`:e.grow>0?`ArrowDown`:`ArrowUp`,i=e.vertical?e.grow>0?`ArrowLeft`:`ArrowRight`:e.grow>0?`ArrowUp`:`ArrowDown`,a=null;t.key===r?a=e.value+n:t.key===i?a=e.value-n:t.key===`Home`?a=e.min:t.key===`End`&&(a=e.max),a!=null&&(t.preventDefault(),e.onChange(eT(a,e.min,e.max)))},children:/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-wb-split-line`,"aria-hidden":`true`})})}function rT(e){let t=y.useRef(null),n=y.useRef({}),r=y.useRef({}),[i,a]=y.useState(e.ids.length),[o,s]=y.useState(null),[c,l]=y.useState(!0),[u,d]=y.useState({left:!1,right:!1}),[f,p]=y.useState(null),m=y.useRef(null),h=y.useRef(e.active),g=e.overflow===`menu`,_=f?(()=>{let t=e.ids.filter(e=>e!==f.id);return t.splice(f.at,0,f.id),t})():e.ids,v=_,b=[];g&&i<_.length&&(v=_.slice(0,Math.max(1,i)),e.active&&_.includes(e.active)&&!v.includes(e.active)&&(v=[...v.slice(0,-1),e.active]),b=_.filter(e=>!v.includes(e)));let x=y.useCallback(()=>{let i=t.current;if(!i)return;let o=e.active?n.current[e.active]:null;s(o?{left:o.offsetLeft+10,right:i.clientWidth-o.offsetLeft-o.offsetWidth+10}:null);let c=i.scrollLeft>1,l=i.scrollLeft+i.clientWidth<i.scrollWidth-1;if(d(e=>e.left===c&&e.right===l?e:{left:c,right:l}),g){for(let[e,t]of Object.entries(n.current))t&&(r.current[e]=t.offsetWidth);let t=0,o=0,s=e.ids.reduce((e,t)=>e+(r.current[t]??80),0),c=i.clientWidth-(s>i.clientWidth?72:0);for(let n of e.ids){if(t+=r.current[n]??80,t>c)break;o++}a(e=>e===o?e:o)}},[e.active,e.ids,g]);y.useLayoutEffect(()=>{h.current!==e.active&&(l(e.ids.indexOf(e.active??``)>e.ids.indexOf(h.current??``)),h.current=e.active),x();let r=t.current;if(!r)return;let i=e.active?n.current[e.active]:null;i&&!g&&(i.offsetLeft<r.scrollLeft?r.scrollLeft=i.offsetLeft-4:i.offsetLeft+i.offsetWidth>r.scrollLeft+r.clientWidth&&(r.scrollLeft=i.offsetLeft+i.offsetWidth-r.clientWidth+4));let a=U(x);return a?.observe(r),()=>a?.disconnect()},[e.active,e.ids,x,g,f]);let S=e.drag,C=S?.over?.region===e.region?S.over:void 0,T=S?e.ids.indexOf(S.id):-1,E=t=>T>=0&&(t===S?.id||t===(e.ids[T+1]??null)),D=(t,r,i)=>{let a=e.views[t],o=t===e.active,s=i[r+1]??null,c=!!C&&!C.noop&&C.before===t,l=!!C&&!C.noop&&C.before===null&&r===i.length-1&&i.length===e.ids.length;return/* @__PURE__ */ (0,A.jsxs)(`button`,{ref:e=>{n.current[t]=e},type:`button`,role:`tab`,"data-id":t,"aria-selected":o,tabIndex:o?0:-1,className:M(`ui-wb-tab`,o&&`is-on`,S?.id===t&&`is-ghost`,f?.id===t&&`is-held`,c&&`has-line`,l&&`has-line-after`),draggable:!!e.setDrag,onClick:()=>e.onPick(t),onKeyDown:t=>{let a=t.key,o=a===`ArrowRight`?r+1:a===`ArrowLeft`?r-1:a===`Home`?0:a===`End`?i.length-1:-1;o<0||o>=i.length||(t.preventDefault(),e.onPick(i[o]),n.current[i[o]]?.focus())},onDragStart:n=>{n.dataTransfer.setData(`text/plain`,t),n.dataTransfer.effectAllowed=`move`,e.setDrag?.({id:t})},onDragEnd:()=>e.setDrag?.(null),onDragOver:n=>{if(!S||!e.setDrag)return;n.preventDefault(),n.stopPropagation();let r=n.currentTarget.getBoundingClientRect(),i=n.clientX>r.left+r.width/2?s:t,a=E(i);C&&C.before===i&&C.noop===a||e.setDrag({id:S.id,over:{region:e.region,before:i,noop:a}})},onDrop:t=>{t.preventDefault(),t.stopPropagation(),S&&C&&!C.noop&&e.onDrop?.(S.id,C.before),e.setDrag?.(null)},children:[a.title,a.attention?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-wb-dot`,"aria-label":w(`有新內容`),role:`img`}):null]},t)},O=e.onReorder?{onPointerDown:t=>{let n=t.target.closest?.(`[data-id]`),r=t.currentTarget,i={id:n?n.getAttribute(`data-id`):null,x:t.clientX,y:t.clientY,scroll:r.scrollLeft,mode:null,timer:void 0};i.timer=setTimeout(()=>{m.current===i&&!i.mode&&i.id&&(i.mode=`drag`,r.setPointerCapture?.(t.pointerId),navigator.vibrate?.(10),p({id:i.id,at:e.ids.indexOf(i.id)}))},300),m.current=i},onPointerMove:e=>{let t=m.current;if(!t)return;let n=e.clientX-t.x;!t.mode&&(Math.abs(n)>8||Math.abs(e.clientY-t.y)>8)&&(clearTimeout(t.timer),t.mode=`scroll`);let r=e.currentTarget;if(t.mode===`scroll`)r.scrollLeft=t.scroll-n;else if(t.mode===`drag`&&t.id){let n=0;r.querySelectorAll(`[data-id]`).forEach(r=>{if(r.getAttribute(`data-id`)===t.id)return;let i=r.getBoundingClientRect();e.clientX>i.left+i.width/2&&n++}),p(e=>e&&e.at===n?e:{id:t.id,at:n});let i=r.getBoundingClientRect();e.clientX<i.left+28?r.scrollLeft-=6:e.clientX>i.right-28&&(r.scrollLeft+=6)}},onPointerUp:()=>{let t=m.current;if(m.current=null,t&&(clearTimeout(t.timer),t.mode===`drag`&&f)){let t=_;p(null),t.join(`
93
93
  `)!==e.ids.join(`
94
- `)&&e.onReorder?.(t)}},onPointerCancel:()=>{let e=m.current;e&&clearTimeout(e.timer),m.current=null,p(null)},onContextMenu:e=>e.preventDefault()}:{};return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-wb-tabbar`,children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:t,className:M(`ui-wb-tabs`,!g&&`is-scroll`,u.left&&`has-more-left`,u.right&&`has-more-right`,e.onReorder&&`is-touch`),role:`tablist`,"aria-label":e.name,onScroll:x,onWheel:e=>{let t=e.currentTarget;!g&&t.scrollWidth>t.clientWidth&&Math.abs(e.deltaY)>Math.abs(e.deltaX)&&(t.scrollLeft+=e.deltaY)},...O,children:[o?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-wb-ind`,"aria-hidden":`true`,style:{left:o.left,right:o.right,transition:hi(`left`,`right`,c)}}):null,v.map((e,t)=>D(e,t,v))]}),b.length?/* @__PURE__ */ (0,A.jsxs)(ig,{children:[/* @__PURE__ */ (0,A.jsxs)(mg,{className:`ui-wb-more`,"aria-label":w(`更多分頁({n} 個)`,{n:b.length}),children:[w(`更多 {n}`,{n:b.length}),/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-down`,size:14})]}),/* @__PURE__ */ (0,A.jsx)(Dh,{children:/* @__PURE__ */ (0,A.jsx)(Lh,{className:`ui-menu-pos`,align:`end`,sideOffset:4,children:/* @__PURE__ */ (0,A.jsx)(wh,{className:`ui-menu`,children:b.map(t=>/* @__PURE__ */ (0,A.jsxs)(ph,{className:`ui-menu-item`,onClick:()=>e.onPick(t),children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-menu-noicon`}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-menu-label`,children:e.views[t].title})]},t))})})})]}):null,/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-wb-tabbtns`,children:e.buttons})]})}function Qw({view:e,onSwipe:t}){let n=y.useRef(null);return/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-wb-panebox`,role:`tabpanel`,onPointerDown:t?e=>n.current={x:e.clientX,y:e.clientY}:void 0,onPointerUp:t?e=>{let r=n.current;if(n.current=null,!r)return;let i=e.clientX-r.x,a=e.clientY-r.y;Math.abs(i)>=48&&Math.abs(i)>Math.abs(a)*1.5&&t(i<0?1:-1)}:void 0,children:e?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-wb-pane`,children:e.render()},e.id):null})}function $w({ref:e,...t}){let n=y.useMemo(()=>t.views??[],[t.views]),r=y.useMemo(()=>Object.fromEntries(n.map(e=>[e.id,e])),[n]),i=`ui-workbench:`+t.id,a=y.useMemo(()=>Kw(n,t.defaultLayout),[n,t.defaultLayout]),[o,s]=y.useState(()=>qw(i,a));G(new Set(n.map(e=>e.id)).size!==n.length,`Workbench`,`two views share an id. Give each view its own id: the layout stores views by id.`);let c=y.useRef(null),[l,u]=y.useState({w:1280,h:800,measured:!1});y.useLayoutEffect(()=>{let e=c.current;if(!e)return;let t=()=>u(t=>t.measured&&t.w===e.clientWidth&&t.h===e.clientHeight?t:{w:e.clientWidth,h:e.clientHeight,measured:!0});t();let n=U(t);return n?.observe(e),()=>n?.disconnect()},[]),y.useEffect(()=>{I(i,JSON.stringify(o))},[i,o]);let d=t.onLayoutChange;y.useEffect(()=>{d?.(o)},[o]);let[f,p]=y.useState({explorer:!1,side:!1}),[m,h]=y.useState({open:!1}),[g,_]=y.useState(null),[v,b]=y.useState(null),[x,S]=y.useState(!1),{w:C,h:T}=l,E=C<600,D=C<960,O=C<1280,k=Math.max(0,T-48),[j,N]=y.useState(null),P=E?3:D?2:+!!O;l.measured&&j===null?N(P):l.measured&&P!==j&&(N(P),p({explorer:!1,side:!1}),h(e=>({...e,open:!1})));let F=Math.max(Hw.panel[0],Math.round(k*.6)),L=E?Math.round(C*.85):Jw(o.size.explorer,Hw.explorer[0],Hw.explorer[1]),R=E?C:Math.min(Jw(o.size.side,Hw.side[0],Hw.side[1]),C-48),B=Jw(o.size.panel,Hw.panel[0],F),V=Math.round(k*.75),H=Jw(g??k*.45,120,Math.max(120,V)),ee=D?f.explorer:o.open.explorer,te=o.side.length>0,ne=o.panel.length>0,W=!E&&te&&(O?f.side:o.open.side),re=!E&&ne&&o.open.panel,ie=!D&&ee,K=!O&&W,q=[...o.side,...o.panel],ae=E&&m.open&&q.length>0,oe=ie?L:0,se=K?R:0,ce=E?ae?H:0:re?B:0,le=e=>{let t=o.active[e];return t&&o[e].includes(t)?t:o[e][0]},J=y.useCallback(e=>s(t=>e(t)),[]),ue=e=>h(t=>{let n=o.active[e]&&o[e].includes(o.active[e])?o.active[e]:o[e][0];return t.open&&t.act===n?{open:!1,act:n}:{open:!0,act:n??q[0]}}),de=e=>{e===`explorer`?D?p(e=>({...e,explorer:!e.explorer})):J(e=>({...e,open:{...e.open,explorer:!e.open.explorer}})):E?ue(e):e===`side`&&O?p(e=>({...e,side:!e.side})):J(t=>({...t,open:{...t.open,[e]:!t.open[e]}}))},fe=y.useRef(de);y.useLayoutEffect(()=>{fe.current=de}),y.useEffect(()=>{let e=e=>{if(e.key===`Escape`){p(e=>e.explorer||e.side?{explorer:!1,side:!1}:e);return}if(!(z?e.metaKey:e.ctrlKey)||e.shiftKey)return;let t=e.key.toLowerCase(),n=e.code;if((t===`b`||n===`KeyB`)&&e.altKey)fe.current(`side`);else if(t===`b`||n===`KeyB`){if(Yw(e.target))return;fe.current(`explorer`)}else if(t===`j`||n===`KeyJ`)fe.current(`panel`);else return;e.preventDefault()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let pe=(e,t,n)=>J(r=>{let i=r.side.includes(e)?`side`:`panel`,a={...r,side:r.side.filter(t=>t!==e),panel:r.panel.filter(t=>t!==e),active:{...r.active},open:{...r.open}},o=a[t],s=n?o.indexOf(n):-1;return s>=0?o.splice(s,0,e):o.push(e),a.active[t]=e,i!==t&&r.active[i]===e&&(a.active[i]=a[i][0]),a.open[t]=!0,a}),me=e=>{let t=le(e);t&&(pe(t,e===`side`?`panel`:`side`,null),e===`side`&&O&&p(e=>({...e,side:!1})),e===`panel`&&O&&p(e=>({...e,side:!0})))},he={resetLayout:()=>{s(Kw(n,t.defaultLayout)),p({explorer:!1,side:!1}),h({open:!1}),_(null)},toggle:de,explorerPicked:()=>{D&&p(e=>({...e,explorer:!1}))},phone:E,show:e=>{let t=o.side.includes(e)?`side`:o.panel.includes(e)?`panel`:null;if(G(!t,`Workbench`,`show('${e}'): no view has this id. Pass the id of one of the views.`),!t)return;let n=c.current?.clientWidth||C,r=n<600,i=n<1280,a=!r&&!(t===`side`&&i);J(n=>({...n,active:{...n.active,[t]:e},open:a?{...n.open,[t]:!0}:n.open})),r?h({open:!0,act:e}):t===`side`&&i&&p(e=>({...e,side:!0}))},layout:o},ge=y.useRef(he);y.useLayoutEffect(()=>{ge.current=he}),y.useImperativeHandle(e,()=>({show:e=>ge.current.show(e),toggle:e=>ge.current.toggle(e),resetLayout:()=>ge.current.resetLayout(),explorerPicked:()=>ge.current.explorerPicked(),get phone(){return ge.current.phone},getLayout:()=>ge.current.layout}),[]);let _e={explorer:w(`檔案總管`),side:w(`右側欄`),panel:w(`下方面板`)},ve={explorer:(z?`⌘`:`Ctrl `)+`B`,side:(z?`⌘⌥`:`Ctrl Alt `)+`B`,panel:(z?`⌘`:`Ctrl `)+`J`},ye=e=>o[e].some(e=>r[e]?.attention),be=(e,t,n)=>/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-wb-toggle`,children:[/* @__PURE__ */ (0,A.jsx)(np,{variant:`quiet`,icon:Gw(e,t),label:_e[e]+`(`+ve[e]+`)`,"aria-pressed":t,onClick:()=>de(e)}),n?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-wb-dot is-on-button`,"aria-hidden":`true`}):null]}),xe=e=>{let t=v?.over;if(!t||t.region!==e)return null;let n=o[e].includes(v.id),r=t.noop?w(`位置不變`):n?w(`放開以排在這裡`):w(`放開以移到{region}`,{region:_e[e]});return/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-wb-dropframe`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(`span`,{children:r})})},Se=e=>({onDragOver:t=>{if(!v)return;t.preventDefault();let n=o[e][o[e].length-1]===v.id,r=v.over;r&&r.region===e&&r.before===null&&r.noop===n||b({id:v.id,over:{region:e,before:null,noop:n}})},onDrop:t=>{t.preventDefault(),v&&!v.over?.noop&&pe(v.id,e,v.over?.region===e?v.over.before:null),b(null)}}),Ce=e=>{let t=le(e);return/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(Zw,{name:_e[e],region:e,ids:o[e],active:t,views:r,onPick:t=>J(n=>({...n,active:{...n.active,[e]:t}})),overflow:`menu`,drag:v,setDrag:b,onDrop:(t,n)=>pe(t,e,n),buttons:/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(np,{variant:`quiet`,icon:`M4 8h15m0 0-3.5-3.5M19 8l-3.5 3.5M20 16H5m0 0 3.5-3.5M5 16l3.5 3.5`,label:w(`把目前分頁移到{region}`,{region:_e[e===`side`?`panel`:`side`]}),onClick:()=>me(e),disabled:!t}),/* @__PURE__ */ (0,A.jsx)(np,{variant:`quiet`,icon:e===`side`?`caret-right`:`caret-down`,label:w(`收合{region}`,{region:_e[e]})+`(`+ve[e]+`)`,onClick:()=>de(e)})]})}),/* @__PURE__ */ (0,A.jsx)(Qw,{view:t?r[t]:void 0}),xe(e)]})},we=t.brand,Te=!!(t.crumbs?.length||t.mainBar),Ee=t.explorerFilter,De=we?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[we.mark?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-wb-mark`,"aria-hidden":`true`,children:we.mark}):null,/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-wb-name`,children:we.name})]}):null,Oe=m.act&&q.includes(m.act)?m.act:q[0],ke=q.indexOf(Oe??``),Ae=e=>{h(t=>({...t,act:e}));let t=o.side.includes(e)?`side`:`panel`;J(n=>({...n,active:{...n.active,[t]:e}}))},je=e=>{let t=o.side.length;J(n=>({...n,side:e.slice(0,t),panel:e.slice(t)}))},Me=e=>{let t=ke+e;if(ke<0||t<0||t>=q.length)return;let n=q.slice();n[ke]=n[t],n[t]=Oe,je(n)},Ne=!!v&&!E&&!K,Pe=!!v&&!E&&!re;return/* @__PURE__ */ (0,A.jsx)(Bw.Provider,{value:he,children:/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:c,className:M(`ui-wb`,E&&`is-phone`,x&&`is-sizing`,t.className),role:`group`,"aria-label":t.label??w(`編輯器`),children:[/* @__PURE__ */ (0,A.jsxs)(`header`,{className:`ui-wb-top`,children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-wb-top-l`,children:[be(`explorer`,ee,!1),we?we.href?/* @__PURE__ */ (0,A.jsx)(`a`,{className:`ui-wb-brand`,href:we.href,"aria-label":E?we.name:void 0,children:De}):/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-wb-brand`,children:De}):null]}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-wb-top-r`,children:[t.actions,n.length?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-wb-sep`,"aria-hidden":`true`}):null,n.length?be(`panel`,E?ae&&o.panel.includes(Oe??``):re,(E?!ae:!re)&&ye(`panel`)):null,n.length?be(`side`,E?ae&&o.side.includes(Oe??``):W,(E?!ae:!W)&&ye(`side`)):null]})]}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-wb-body`,children:[Te?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-wb-mainbar`,style:{left:oe,right:se},children:[t.crumbs?.length?/* @__PURE__ */ (0,A.jsx)(tp,{className:`ui-wb-crumbs`,items:t.crumbs}):/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-wb-mainbar-fill`}),t.mainBar?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-wb-mainbar-btns`,children:t.mainBar}):null]}):null,/* @__PURE__ */ (0,A.jsx)(`main`,{className:`ui-wb-main`,style:{left:oe,right:se,bottom:ce,top:Te?36:0},children:t.children}),t.explorer||t.explorerHead||t.explorerFoot||Ee?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[D?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,tabIndex:-1,className:M(`ui-wb-scrim`,ee&&`is-open`),"aria-label":w(`關閉{region}`,{region:_e.explorer}),onClick:()=>p(e=>({...e,explorer:!1}))}):null,/* @__PURE__ */ (0,A.jsxs)(`aside`,{className:M(`ui-wb-ex`,D?`is-drawer`:`is-docked`,ee?`is-open`:`is-shut`),style:{width:L},"aria-label":_e.explorer,inert:!ee,children:[Ee?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-wb-exfilter`,children:/* @__PURE__ */ (0,A.jsx)(ey,{value:Ee.value,onChange:Ee.onChange,label:Ee.label??w(`篩選`),placeholder:Ee.label??w(`篩選`)})}):null,t.explorerHead?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-wb-exhead`,children:t.explorerHead}):null,/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-wb-exbody`,children:t.explorer}),t.explorerFoot?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-wb-exfoot`,children:t.explorerFoot}):null]}),ie?/* @__PURE__ */ (0,A.jsx)(Xw,{label:w(`{region}寬度`,{region:_e.explorer}),vertical:!0,grow:1,value:L,min:Hw.explorer[0],max:Hw.explorer[1],onChange:e=>J(t=>({...t,size:{...t.size,explorer:e}})),onReset:()=>J(e=>({...e,size:{...e.size,explorer:a.size.explorer}})),onDrag:S,style:{left:L}}):null]}):null,!E&&ne?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`section`,{className:M(`ui-wb-panel`,re?`is-open`:`is-shut`,v?.over?.region===`panel`&&`is-dropping`),style:{left:oe,right:se,height:B},"aria-label":_e.panel,inert:!re,...Se(`panel`),children:Ce(`panel`)}),re?/* @__PURE__ */ (0,A.jsx)(Xw,{label:w(`{region}高度`,{region:_e.panel}),vertical:!1,grow:-1,value:B,min:Hw.panel[0],max:F,onChange:e=>J(t=>({...t,size:{...t.size,panel:e}})),onReset:()=>J(e=>({...e,size:{...e.size,panel:a.size.panel}})),onDrag:S,style:{left:oe,right:se,bottom:B}}):null]}):null,!E&&te?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[O?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,tabIndex:-1,className:M(`ui-wb-scrim`,W&&`is-open`),"aria-label":w(`關閉{region}`,{region:_e.side}),onClick:()=>p(e=>({...e,side:!1}))}):null,/* @__PURE__ */ (0,A.jsx)(`aside`,{className:M(`ui-wb-side`,O?`is-drawer`:`is-docked`,W?`is-open`:`is-shut`,v?.over?.region===`side`&&`is-dropping`),style:{width:R},"aria-label":_e.side,inert:!W,...Se(`side`),children:Ce(`side`)}),K?/* @__PURE__ */ (0,A.jsx)(Xw,{label:w(`{region}寬度`,{region:_e.side}),vertical:!0,grow:-1,value:R,min:Hw.side[0],max:Hw.side[1],onChange:e=>J(t=>({...t,size:{...t.size,side:e}})),onReset:()=>J(e=>({...e,size:{...e.size,side:a.size.side}})),onDrag:S,style:{right:R}}):null]}):null,Ne?/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-wb-dropzone is-side`,v?.over?.region===`side`&&`is-over`),style:{bottom:(re?B:0)+8},...Se(`side`),children:w(`放開以移到{region}`,{region:_e.side})}):null,Pe?/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-wb-dropzone is-panel`,v?.over?.region===`panel`&&`is-over`),style:{left:oe+8,right:se+(Ne?120:8)},...Se(`panel`),children:w(`放開以移到{region}`,{region:_e.panel})}):null,E&&q.length?/* @__PURE__ */ (0,A.jsxs)(`section`,{className:M(`ui-wb-sheet`,ae?`is-open`:`is-shut`),style:{height:H},"aria-label":w(`面板分頁`),inert:!ae,children:[/* @__PURE__ */ (0,A.jsx)(Xw,{label:w(`面板高度`),vertical:!1,grow:-1,value:H,min:120,max:Math.max(120,V),onChange:_,onReset:()=>_(null),onDrag:S,style:{top:0,left:0,right:0}}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-wb-grab`,"aria-hidden":`true`}),/* @__PURE__ */ (0,A.jsx)(Zw,{name:w(`面板分頁`),region:`sheet`,ids:q,active:Oe,views:r,onPick:Ae,overflow:`scroll`,onReorder:je,buttons:/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(np,{variant:`quiet`,icon:`caret-left`,label:w(`目前分頁往左移`),disabled:ke<=0,onClick:()=>Me(-1)}),/* @__PURE__ */ (0,A.jsx)(np,{variant:`quiet`,icon:`caret-right`,label:w(`目前分頁往右移`),disabled:ke<0||ke>=q.length-1,onClick:()=>Me(1)}),/* @__PURE__ */ (0,A.jsx)(np,{variant:`quiet`,icon:`caret-down`,label:w(`收起面板`),onClick:()=>h(e=>({...e,open:!1}))})]})}),/* @__PURE__ */ (0,A.jsx)(Qw,{view:Oe?r[Oe]:void 0,onSwipe:e=>{let t=ke+e;t>=0&&t<q.length&&Ae(q[t])}}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-wb-dots`,"aria-hidden":`true`,children:q.map(e=>/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-wb-pagedot`,e===Oe&&`is-on`)},e))})]}):null]})]})})}var eT=/* @__PURE__ */ c({AccentPicker:()=>Pm,ActionBar:()=>Fg,AiMark:()=>gb,Alert:()=>Lg,AppShell:()=>im,Badge:()=>zg,BarChart:()=>x_,Breadcrumb:()=>tp,Button:()=>Xp,Calendar:()=>S_,Card:()=>w_,Checkbox:()=>k_,CodeText:()=>Y_,CodeView:()=>Yv,CommandPalette:()=>Qv,ConsoleLayout:()=>Fx,DangerZone:()=>$v,DataTable:()=>Qy,DatePicker:()=>$y,DateRangePicker:()=>tb,DetailList:()=>nb,Dialog:()=>Zp,Drawer:()=>Qp,EmptyState:()=>ob,ErrorPage:()=>cb,EventTimeline:()=>Nx,FileUpload:()=>ub,FormGrid:()=>db,GraphDefs:()=>fb,GraphLegend:()=>hb,Grid:()=>am,Icon:()=>Y,IconButton:()=>np,InlineCode:()=>K_,KpiCard:()=>ax,LayerGraph:()=>Cx,LineChart:()=>Ox,LoadingBar:()=>Lx,LoginCard:()=>zx,MOTION:()=>mi,Markdown:()=>qb,Menu:()=>Pg,Meter:()=>kx,MobileTabBar:()=>ap,MultiSelect:()=>_C,NotificationBell:()=>vC,Page:()=>om,Popover:()=>yC,ProgressBar:()=>lb,ProgressRing:()=>bC,ProjectSwitcher:()=>SC,RadioGroup:()=>CC,SearchField:()=>ey,Section:()=>tx,SectionGroup:()=>nx,SectionGroupToggle:()=>rx,SegmentedControl:()=>fw,Select:()=>ow,SettingsLayout:()=>cw,SettingsSection:()=>lw,SideNav:()=>ep,Skeleton:()=>uw,SplitPane:()=>ab,StatusBand:()=>wx,StatusLegend:()=>Tx,Suggestion:()=>dw,Switch:()=>ox,Tabs:()=>ty,Tag:()=>pw,Term:()=>xv,TextArea:()=>mw,TextField:()=>Rx,ThemePicker:()=>gw,TimeControl:()=>Ix,Toast:()=>sw,Tooltip:()=>Zf,TopBar:()=>ip,Tour:()=>Tw,TreeList:()=>Iw,Workbench:()=>$w,ZoneMap:()=>jx,addMessages:()=>D,announce:()=>bi,consoleZoom:()=>Px,divergeToken:()=>jm,focusMain:()=>em,format:()=>a_,heatToken:()=>Am,icons:()=>zw,initTheme:()=>Om,isCodeRef:()=>J_,preloadIcons:()=>si,safeHref:()=>Mb,setAccent:()=>Em,setLocale:()=>E,setTheme:()=>pm,t:()=>w,textOn:()=>km,useTour:()=>vw,useWorkbench:()=>Vw});ai(Gr),window.React=y,window.ReactDOM={...b,...x},window.UI=eT})();
94
+ `)&&e.onReorder?.(t)}},onPointerCancel:()=>{let e=m.current;e&&clearTimeout(e.timer),m.current=null,p(null)},onContextMenu:e=>e.preventDefault()}:{};return/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-wb-tabbar`,children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:t,className:M(`ui-wb-tabs`,!g&&`is-scroll`,u.left&&`has-more-left`,u.right&&`has-more-right`,e.onReorder&&`is-touch`),role:`tablist`,"aria-label":e.name,onScroll:x,onWheel:e=>{let t=e.currentTarget;!g&&t.scrollWidth>t.clientWidth&&Math.abs(e.deltaY)>Math.abs(e.deltaX)&&(t.scrollLeft+=e.deltaY)},...O,children:[o?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-wb-ind`,"aria-hidden":`true`,style:{left:o.left,right:o.right,transition:hi(`left`,`right`,c)}}):null,v.map((e,t)=>D(e,t,v))]}),b.length?/* @__PURE__ */ (0,A.jsxs)(fg,{children:[/* @__PURE__ */ (0,A.jsxs)(Sg,{className:`ui-wb-more`,"aria-label":w(`更多分頁({n} 個)`,{n:b.length}),children:[w(`更多 {n}`,{n:b.length}),/* @__PURE__ */ (0,A.jsx)(Y,{name:`caret-down`,size:14})]}),/* @__PURE__ */ (0,A.jsx)(Fh,{children:/* @__PURE__ */ (0,A.jsx)(Gh,{className:`ui-menu-pos`,align:`end`,sideOffset:4,children:/* @__PURE__ */ (0,A.jsx)(Mh,{className:`ui-menu`,children:b.map(t=>/* @__PURE__ */ (0,A.jsxs)(xh,{className:`ui-menu-item`,onClick:()=>e.onPick(t),children:[/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-menu-noicon`}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-menu-label`,children:e.views[t].title})]},t))})})})]}):null,/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-wb-tabbtns`,children:e.buttons})]})}function iT({view:e,onSwipe:t}){let n=y.useRef(null);return/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-wb-panebox`,role:`tabpanel`,onPointerDown:t?e=>n.current={x:e.clientX,y:e.clientY}:void 0,onPointerUp:t?e=>{let r=n.current;if(n.current=null,!r)return;let i=e.clientX-r.x,a=e.clientY-r.y;Math.abs(i)>=48&&Math.abs(i)>Math.abs(a)*1.5&&t(i<0?1:-1)}:void 0,children:e?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-wb-pane`,children:e.render()},e.id):null})}function aT({ref:e,...t}){let n=y.useMemo(()=>t.views??[],[t.views]),r=y.useMemo(()=>Object.fromEntries(n.map(e=>[e.id,e])),[n]),i=`ui-workbench:`+t.id,a=y.useMemo(()=>Qw(n,t.defaultLayout),[n,t.defaultLayout]),[o,s]=y.useState(()=>$w(i,a));G(new Set(n.map(e=>e.id)).size!==n.length,`Workbench`,`two views share an id. Give each view its own id: the layout stores views by id.`);let c=y.useRef(null),[l,u]=y.useState({w:1280,h:800,measured:!1});y.useLayoutEffect(()=>{let e=c.current;if(!e)return;let t=()=>u(t=>t.measured&&t.w===e.clientWidth&&t.h===e.clientHeight?t:{w:e.clientWidth,h:e.clientHeight,measured:!0});t();let n=U(t);return n?.observe(e),()=>n?.disconnect()},[]),y.useEffect(()=>{I(i,JSON.stringify(o))},[i,o]);let d=t.onLayoutChange;y.useEffect(()=>{d?.(o)},[o]);let[f,p]=y.useState({explorer:!1,side:!1}),[m,h]=y.useState({open:!1}),[g,_]=y.useState(null),[v,b]=y.useState(null),[x,S]=y.useState(!1),{w:C,h:T}=l,E=C<600,D=C<960,O=C<1280,k=Math.max(0,T-48),[j,N]=y.useState(null),P=E?3:D?2:+!!O;l.measured&&j===null?N(P):l.measured&&P!==j&&(N(P),p({explorer:!1,side:!1}),h(e=>({...e,open:!1})));let F=Math.max(Jw.panel[0],Math.round(k*.6)),L=E?Math.round(C*.85):eT(o.size.explorer,Jw.explorer[0],Jw.explorer[1]),R=E?C:Math.min(eT(o.size.side,Jw.side[0],Jw.side[1]),C-48),B=eT(o.size.panel,Jw.panel[0],F),V=Math.round(k*.75),H=eT(g??k*.45,120,Math.max(120,V)),ee=D?f.explorer:o.open.explorer,te=o.side.length>0,ne=o.panel.length>0,W=!E&&te&&(O?f.side:o.open.side),re=!E&&ne&&o.open.panel,ie=!D&&ee,K=!O&&W,q=[...o.side,...o.panel],ae=E&&m.open&&q.length>0,oe=ie?L:0,se=K?R:0,ce=E?ae?H:0:re?B:0,le=e=>{let t=o.active[e];return t&&o[e].includes(t)?t:o[e][0]},J=y.useCallback(e=>s(t=>e(t)),[]),ue=e=>h(t=>{let n=o.active[e]&&o[e].includes(o.active[e])?o.active[e]:o[e][0];return t.open&&t.act===n?{open:!1,act:n}:{open:!0,act:n??q[0]}}),de=e=>{e===`explorer`?D?p(e=>({...e,explorer:!e.explorer})):J(e=>({...e,open:{...e.open,explorer:!e.open.explorer}})):E?ue(e):e===`side`&&O?p(e=>({...e,side:!e.side})):J(t=>({...t,open:{...t.open,[e]:!t.open[e]}}))},fe=y.useRef(de);y.useLayoutEffect(()=>{fe.current=de}),y.useEffect(()=>{let e=e=>{if(e.key===`Escape`){p(e=>e.explorer||e.side?{explorer:!1,side:!1}:e);return}if(!(z?e.metaKey:e.ctrlKey)||e.shiftKey)return;let t=e.key.toLowerCase(),n=e.code;if((t===`b`||n===`KeyB`)&&e.altKey)fe.current(`side`);else if(t===`b`||n===`KeyB`){if(tT(e.target))return;fe.current(`explorer`)}else if(t===`j`||n===`KeyJ`)fe.current(`panel`);else return;e.preventDefault()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let pe=(e,t,n)=>J(r=>{let i=r.side.includes(e)?`side`:`panel`,a={...r,side:r.side.filter(t=>t!==e),panel:r.panel.filter(t=>t!==e),active:{...r.active},open:{...r.open}},o=a[t],s=n?o.indexOf(n):-1;return s>=0?o.splice(s,0,e):o.push(e),a.active[t]=e,i!==t&&r.active[i]===e&&(a.active[i]=a[i][0]),a.open[t]=!0,a}),me=e=>{let t=le(e);t&&(pe(t,e===`side`?`panel`:`side`,null),e===`side`&&O&&p(e=>({...e,side:!1})),e===`panel`&&O&&p(e=>({...e,side:!0})))},he={resetLayout:()=>{s(Qw(n,t.defaultLayout)),p({explorer:!1,side:!1}),h({open:!1}),_(null)},toggle:de,explorerPicked:()=>{D&&p(e=>({...e,explorer:!1}))},phone:E,show:e=>{let t=o.side.includes(e)?`side`:o.panel.includes(e)?`panel`:null;if(G(!t,`Workbench`,`show('${e}'): no view has this id. Pass the id of one of the views.`),!t)return;let n=c.current?.clientWidth||C,r=n<600,i=n<1280,a=!r&&!(t===`side`&&i);J(n=>({...n,active:{...n.active,[t]:e},open:a?{...n.open,[t]:!0}:n.open})),r?h({open:!0,act:e}):t===`side`&&i&&p(e=>({...e,side:!0}))},layout:o},ge=y.useRef(he);y.useLayoutEffect(()=>{ge.current=he}),y.useImperativeHandle(e,()=>({show:e=>ge.current.show(e),toggle:e=>ge.current.toggle(e),resetLayout:()=>ge.current.resetLayout(),explorerPicked:()=>ge.current.explorerPicked(),get phone(){return ge.current.phone},getLayout:()=>ge.current.layout}),[]);let _e={explorer:w(`檔案總管`),side:w(`右側欄`),panel:w(`下方面板`)},ve={explorer:(z?`⌘`:`Ctrl `)+`B`,side:(z?`⌘⌥`:`Ctrl Alt `)+`B`,panel:(z?`⌘`:`Ctrl `)+`J`},ye=e=>o[e].some(e=>r[e]?.attention),be=(e,t,n)=>/* @__PURE__ */ (0,A.jsxs)(`span`,{className:`ui-wb-toggle`,children:[/* @__PURE__ */ (0,A.jsx)(np,{variant:`quiet`,icon:Zw(e,t),label:_e[e]+`(`+ve[e]+`)`,"aria-pressed":t,onClick:()=>de(e)}),n?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-wb-dot is-on-button`,"aria-hidden":`true`}):null]}),xe=e=>{let t=v?.over;if(!t||t.region!==e)return null;let n=o[e].includes(v.id),r=t.noop?w(`位置不變`):n?w(`放開以排在這裡`):w(`放開以移到{region}`,{region:_e[e]});return/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-wb-dropframe`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,A.jsx)(`span`,{children:r})})},Se=e=>({onDragOver:t=>{if(!v)return;t.preventDefault();let n=o[e][o[e].length-1]===v.id,r=v.over;r&&r.region===e&&r.before===null&&r.noop===n||b({id:v.id,over:{region:e,before:null,noop:n}})},onDrop:t=>{t.preventDefault(),v&&!v.over?.noop&&pe(v.id,e,v.over?.region===e?v.over.before:null),b(null)}}),Ce=e=>{let t=le(e);return/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(rT,{name:_e[e],region:e,ids:o[e],active:t,views:r,onPick:t=>J(n=>({...n,active:{...n.active,[e]:t}})),overflow:`menu`,drag:v,setDrag:b,onDrop:(t,n)=>pe(t,e,n),buttons:/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(np,{variant:`quiet`,icon:`M4 8h15m0 0-3.5-3.5M19 8l-3.5 3.5M20 16H5m0 0 3.5-3.5M5 16l3.5 3.5`,label:w(`把目前分頁移到{region}`,{region:_e[e===`side`?`panel`:`side`]}),onClick:()=>me(e),disabled:!t}),/* @__PURE__ */ (0,A.jsx)(np,{variant:`quiet`,icon:e===`side`?`caret-right`:`caret-down`,label:w(`收合{region}`,{region:_e[e]})+`(`+ve[e]+`)`,onClick:()=>de(e)})]})}),/* @__PURE__ */ (0,A.jsx)(iT,{view:t?r[t]:void 0}),xe(e)]})},we=t.brand,Te=!!(t.crumbs?.length||t.mainBar),Ee=t.explorerFilter,De=we?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[we.mark?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-wb-mark`,"aria-hidden":`true`,children:we.mark}):null,/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-wb-name`,children:we.name})]}):null,Oe=m.act&&q.includes(m.act)?m.act:q[0],ke=q.indexOf(Oe??``),Ae=e=>{h(t=>({...t,act:e}));let t=o.side.includes(e)?`side`:`panel`;J(n=>({...n,active:{...n.active,[t]:e}}))},je=e=>{let t=o.side.length;J(n=>({...n,side:e.slice(0,t),panel:e.slice(t)}))},Me=e=>{let t=ke+e;if(ke<0||t<0||t>=q.length)return;let n=q.slice();n[ke]=n[t],n[t]=Oe,je(n)},Ne=!!v&&!E&&!K,Pe=!!v&&!E&&!re;return/* @__PURE__ */ (0,A.jsx)(Kw.Provider,{value:he,children:/* @__PURE__ */ (0,A.jsxs)(`div`,{ref:c,className:M(`ui-wb`,E&&`is-phone`,x&&`is-sizing`,t.className),role:`group`,"aria-label":t.label??w(`編輯器`),children:[/* @__PURE__ */ (0,A.jsxs)(`header`,{className:`ui-wb-top`,children:[/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-wb-top-l`,children:[be(`explorer`,ee,!1),we?we.href?/* @__PURE__ */ (0,A.jsx)(`a`,{className:`ui-wb-brand`,href:we.href,"aria-label":E?we.name:void 0,children:De}):/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-wb-brand`,children:De}):null]}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-wb-top-r`,children:[t.actions,n.length?/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-wb-sep`,"aria-hidden":`true`}):null,n.length?be(`panel`,E?ae&&o.panel.includes(Oe??``):re,(E?!ae:!re)&&ye(`panel`)):null,n.length?be(`side`,E?ae&&o.side.includes(Oe??``):W,(E?!ae:!W)&&ye(`side`)):null]})]}),/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-wb-body`,children:[Te?/* @__PURE__ */ (0,A.jsxs)(`div`,{className:`ui-wb-mainbar`,style:{left:oe,right:se},children:[t.crumbs?.length?/* @__PURE__ */ (0,A.jsx)(tp,{className:`ui-wb-crumbs`,items:t.crumbs}):/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-wb-mainbar-fill`}),t.mainBar?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-wb-mainbar-btns`,children:t.mainBar}):null]}):null,/* @__PURE__ */ (0,A.jsx)(`main`,{className:`ui-wb-main`,style:{left:oe,right:se,bottom:ce,top:Te?36:0},children:t.children}),t.explorer||t.explorerHead||t.explorerFoot||Ee?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[D?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,tabIndex:-1,className:M(`ui-wb-scrim`,ee&&`is-open`),"aria-label":w(`關閉{region}`,{region:_e.explorer}),onClick:()=>p(e=>({...e,explorer:!1}))}):null,/* @__PURE__ */ (0,A.jsxs)(`aside`,{className:M(`ui-wb-ex`,D?`is-drawer`:`is-docked`,ee?`is-open`:`is-shut`),style:{width:L},"aria-label":_e.explorer,inert:!ee,children:[Ee?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-wb-exfilter`,children:/* @__PURE__ */ (0,A.jsx)(iy,{value:Ee.value,onChange:Ee.onChange,label:Ee.label??w(`篩選`),placeholder:Ee.label??w(`篩選`)})}):null,t.explorerHead?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-wb-exhead`,children:t.explorerHead}):null,/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-wb-exbody`,children:t.explorer}),t.explorerFoot?/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-wb-exfoot`,children:t.explorerFoot}):null]}),ie?/* @__PURE__ */ (0,A.jsx)(nT,{label:w(`{region}寬度`,{region:_e.explorer}),vertical:!0,grow:1,value:L,min:Jw.explorer[0],max:Jw.explorer[1],onChange:e=>J(t=>({...t,size:{...t.size,explorer:e}})),onReset:()=>J(e=>({...e,size:{...e.size,explorer:a.size.explorer}})),onDrag:S,style:{left:L}}):null]}):null,!E&&ne?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(`section`,{className:M(`ui-wb-panel`,re?`is-open`:`is-shut`,v?.over?.region===`panel`&&`is-dropping`),style:{left:oe,right:se,height:B},"aria-label":_e.panel,inert:!re,...Se(`panel`),children:Ce(`panel`)}),re?/* @__PURE__ */ (0,A.jsx)(nT,{label:w(`{region}高度`,{region:_e.panel}),vertical:!1,grow:-1,value:B,min:Jw.panel[0],max:F,onChange:e=>J(t=>({...t,size:{...t.size,panel:e}})),onReset:()=>J(e=>({...e,size:{...e.size,panel:a.size.panel}})),onDrag:S,style:{left:oe,right:se,bottom:B}}):null]}):null,!E&&te?/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[O?/* @__PURE__ */ (0,A.jsx)(`button`,{type:`button`,tabIndex:-1,className:M(`ui-wb-scrim`,W&&`is-open`),"aria-label":w(`關閉{region}`,{region:_e.side}),onClick:()=>p(e=>({...e,side:!1}))}):null,/* @__PURE__ */ (0,A.jsx)(`aside`,{className:M(`ui-wb-side`,O?`is-drawer`:`is-docked`,W?`is-open`:`is-shut`,v?.over?.region===`side`&&`is-dropping`),style:{width:R},"aria-label":_e.side,inert:!W,...Se(`side`),children:Ce(`side`)}),K?/* @__PURE__ */ (0,A.jsx)(nT,{label:w(`{region}寬度`,{region:_e.side}),vertical:!0,grow:-1,value:R,min:Jw.side[0],max:Jw.side[1],onChange:e=>J(t=>({...t,size:{...t.size,side:e}})),onReset:()=>J(e=>({...e,size:{...e.size,side:a.size.side}})),onDrag:S,style:{right:R}}):null]}):null,Ne?/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-wb-dropzone is-side`,v?.over?.region===`side`&&`is-over`),style:{bottom:(re?B:0)+8},...Se(`side`),children:w(`放開以移到{region}`,{region:_e.side})}):null,Pe?/* @__PURE__ */ (0,A.jsx)(`div`,{className:M(`ui-wb-dropzone is-panel`,v?.over?.region===`panel`&&`is-over`),style:{left:oe+8,right:se+(Ne?120:8)},...Se(`panel`),children:w(`放開以移到{region}`,{region:_e.panel})}):null,E&&q.length?/* @__PURE__ */ (0,A.jsxs)(`section`,{className:M(`ui-wb-sheet`,ae?`is-open`:`is-shut`),style:{height:H},"aria-label":w(`面板分頁`),inert:!ae,children:[/* @__PURE__ */ (0,A.jsx)(nT,{label:w(`面板高度`),vertical:!1,grow:-1,value:H,min:120,max:Math.max(120,V),onChange:_,onReset:()=>_(null),onDrag:S,style:{top:0,left:0,right:0}}),/* @__PURE__ */ (0,A.jsx)(`span`,{className:`ui-wb-grab`,"aria-hidden":`true`}),/* @__PURE__ */ (0,A.jsx)(rT,{name:w(`面板分頁`),region:`sheet`,ids:q,active:Oe,views:r,onPick:Ae,overflow:`scroll`,onReorder:je,buttons:/* @__PURE__ */ (0,A.jsxs)(A.Fragment,{children:[/* @__PURE__ */ (0,A.jsx)(np,{variant:`quiet`,icon:`caret-left`,label:w(`目前分頁往左移`),disabled:ke<=0,onClick:()=>Me(-1)}),/* @__PURE__ */ (0,A.jsx)(np,{variant:`quiet`,icon:`caret-right`,label:w(`目前分頁往右移`),disabled:ke<0||ke>=q.length-1,onClick:()=>Me(1)}),/* @__PURE__ */ (0,A.jsx)(np,{variant:`quiet`,icon:`caret-down`,label:w(`收起面板`),onClick:()=>h(e=>({...e,open:!1}))})]})}),/* @__PURE__ */ (0,A.jsx)(iT,{view:Oe?r[Oe]:void 0,onSwipe:e=>{let t=ke+e;t>=0&&t<q.length&&Ae(q[t])}}),/* @__PURE__ */ (0,A.jsx)(`div`,{className:`ui-wb-dots`,"aria-hidden":`true`,children:q.map(e=>/* @__PURE__ */ (0,A.jsx)(`span`,{className:M(`ui-wb-pagedot`,e===Oe&&`is-on`)},e))})]}):null]})]})})}var oT=/* @__PURE__ */ c({AccentPicker:()=>Hm,ActionBar:()=>Ug,AiMark:()=>bb,Alert:()=>Gg,AppShell:()=>fm,Badge:()=>qg,BarChart:()=>k_,Breadcrumb:()=>tp,Button:()=>Xp,Calendar:()=>A_,Card:()=>M_,Checkbox:()=>L_,CodeText:()=>rm,CodeView:()=>$v,CommandPalette:()=>ny,ConsoleLayout:()=>Vx,DangerZone:()=>ry,DataTable:()=>nb,DatePicker:()=>rb,DateRangePicker:()=>ab,DetailList:()=>ob,Dialog:()=>am,Drawer:()=>om,EmptyState:()=>ub,ErrorPage:()=>fb,EventTimeline:()=>zx,FileUpload:()=>mb,FormGrid:()=>hb,GraphDefs:()=>gb,GraphLegend:()=>yb,Grid:()=>pm,Icon:()=>Y,IconButton:()=>np,InlineCode:()=>em,KpiCard:()=>ux,LayerGraph:()=>kx,LineChart:()=>Px,LoadingBar:()=>Ux,LoginCard:()=>Gx,MOTION:()=>mi,Markdown:()=>Qb,Menu:()=>Hg,Meter:()=>Fx,MobileTabBar:()=>ap,MultiSelect:()=>CC,NotificationBell:()=>wC,Page:()=>mm,Popover:()=>TC,ProgressBar:()=>pb,ProgressRing:()=>EC,ProjectSwitcher:()=>OC,RadioGroup:()=>kC,SearchField:()=>iy,Section:()=>ox,SectionGroup:()=>sx,SectionGroupToggle:()=>cx,SegmentedControl:()=>vw,Select:()=>fw,SettingsLayout:()=>mw,SettingsSection:()=>hw,SideNav:()=>ep,Skeleton:()=>gw,SplitPane:()=>lb,StatusBand:()=>Ax,StatusLegend:()=>jx,Suggestion:()=>_w,Switch:()=>dx,Tabs:()=>ay,Tag:()=>yw,Term:()=>Tv,TextArea:()=>bw,TextField:()=>Wx,ThemePicker:()=>Sw,TimeControl:()=>Hx,Toast:()=>pw,Tooltip:()=>Zf,TopBar:()=>ip,Tour:()=>jw,TreeList:()=>Hw,Workbench:()=>aT,ZoneMap:()=>Lx,addMessages:()=>D,announce:()=>bi,consoleZoom:()=>Bx,divergeToken:()=>zm,focusMain:()=>cm,format:()=>p_,heatToken:()=>Rm,icons:()=>Gw,initTheme:()=>Im,isCodeRef:()=>nm,preloadIcons:()=>si,safeHref:()=>Ib,setAccent:()=>Pm,setLocale:()=>E,setTheme:()=>xm,t:()=>w,textOn:()=>Lm,useTour:()=>ww,useWorkbench:()=>qw});ai(Gr),window.React=y,window.ReactDOM={...b,...x},window.UI=oT})();
95
95
  //# sourceMappingURL=bundle.js.map