@purpur/library 9.8.0 → 9.8.1

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 (204) hide show
  1. package/CHANGELOG.json +27 -0
  2. package/CHANGELOG.md +13 -1
  3. package/dist/{RichText-yobCUjTD.js → RichText-BAVZadzi.js} +2 -2
  4. package/dist/{RichText-yobCUjTD.js.map → RichText-BAVZadzi.js.map} +1 -1
  5. package/dist/{RichText-jZ-sHV-u.mjs → RichText-D4vznH1B.mjs} +2 -2
  6. package/dist/{RichText-jZ-sHV-u.mjs.map → RichText-D4vznH1B.mjs.map} +1 -1
  7. package/dist/{accordion-CIU4U8-4.mjs → accordion-B6OoQ4uZ.mjs} +2 -2
  8. package/dist/{accordion-CIU4U8-4.mjs.map → accordion-B6OoQ4uZ.mjs.map} +1 -1
  9. package/dist/{accordion-DyhOG54L.js → accordion-BfpN5h4C.js} +2 -2
  10. package/dist/{accordion-DyhOG54L.js.map → accordion-BfpN5h4C.js.map} +1 -1
  11. package/dist/accordion.cjs.js +1 -1
  12. package/dist/accordion.es.js +1 -1
  13. package/dist/{autocomplete-Bbth0nDG.js → autocomplete-CcVDJbwS.js} +2 -2
  14. package/dist/{autocomplete-Bbth0nDG.js.map → autocomplete-CcVDJbwS.js.map} +1 -1
  15. package/dist/{autocomplete-A9-Ni60G.mjs → autocomplete-DF17Zm7Q.mjs} +2 -2
  16. package/dist/{autocomplete-A9-Ni60G.mjs.map → autocomplete-DF17Zm7Q.mjs.map} +1 -1
  17. package/dist/autocomplete.cjs.js +1 -1
  18. package/dist/autocomplete.es.js +1 -1
  19. package/dist/avatar-BDF2KuEh.mjs +28 -0
  20. package/dist/avatar-BDF2KuEh.mjs.map +1 -0
  21. package/dist/avatar-nDQ8fk-2.js +2 -0
  22. package/dist/avatar-nDQ8fk-2.js.map +1 -0
  23. package/dist/avatar.cjs.js +1 -1
  24. package/dist/avatar.es.js +1 -1
  25. package/dist/{card-DFdUs5RG.js → card-pdsBEJif.js} +2 -2
  26. package/dist/{card-DFdUs5RG.js.map → card-pdsBEJif.js.map} +1 -1
  27. package/dist/{card-C2mdp-ur.mjs → card-t2ZkZ82G.mjs} +2 -2
  28. package/dist/{card-C2mdp-ur.mjs.map → card-t2ZkZ82G.mjs.map} +1 -1
  29. package/dist/card.cjs.js +1 -1
  30. package/dist/card.es.js +1 -1
  31. package/dist/{checkbox-BHTx89JQ.mjs → checkbox-DaRtZXrE.mjs} +2 -2
  32. package/dist/{checkbox-BHTx89JQ.mjs.map → checkbox-DaRtZXrE.mjs.map} +1 -1
  33. package/dist/{checkbox-CDNcNv6d.js → checkbox-qjWQEoa5.js} +2 -2
  34. package/dist/{checkbox-CDNcNv6d.js.map → checkbox-qjWQEoa5.js.map} +1 -1
  35. package/dist/checkbox.cjs.js +1 -1
  36. package/dist/checkbox.es.js +1 -1
  37. package/dist/comparison-table-DHFpydbq.js +2 -0
  38. package/dist/comparison-table-DHFpydbq.js.map +1 -0
  39. package/dist/comparison-table-DQJL1IVC.mjs +293 -0
  40. package/dist/comparison-table-DQJL1IVC.mjs.map +1 -0
  41. package/dist/comparison-table.cjs.js +1 -1
  42. package/dist/comparison-table.es.js +1 -1
  43. package/dist/components/alert-badge/src/alert-badge.visual.fixtures.d.ts +15 -0
  44. package/dist/components/alert-badge/src/alert-badge.visual.fixtures.d.ts.map +1 -0
  45. package/dist/components/avatar/src/avatar.d.ts +2 -2
  46. package/dist/components/avatar/src/avatar.d.ts.map +1 -1
  47. package/dist/components/avatar/src/avatar.visual.fixtures.d.ts +14 -0
  48. package/dist/components/avatar/src/avatar.visual.fixtures.d.ts.map +1 -0
  49. package/dist/components/badge/src/badge.visual.fixtures.d.ts.map +1 -1
  50. package/dist/components/comparison-table/src/components/OptionCard/option-card.d.ts +1 -1
  51. package/dist/components/comparison-table/src/components/OptionCard/option-card.d.ts.map +1 -1
  52. package/dist/components/countdown/src/countdown.d.ts.map +1 -1
  53. package/dist/components/countdown/src/countdown.types.d.ts +10 -0
  54. package/dist/components/countdown/src/countdown.types.d.ts.map +1 -1
  55. package/dist/components/countdown/src/countdown.visual.fixtures.d.ts +13 -0
  56. package/dist/components/countdown/src/countdown.visual.fixtures.d.ts.map +1 -0
  57. package/dist/components/countdown/src/utils.d.ts +1 -1
  58. package/dist/components/countdown/src/utils.d.ts.map +1 -1
  59. package/dist/components/search-field/src/search-field.visual.fixtures.d.ts +14 -0
  60. package/dist/components/search-field/src/search-field.visual.fixtures.d.ts.map +1 -0
  61. package/dist/{content-block-CakKeJtN.mjs → content-block-CDMrz41K.mjs} +2 -2
  62. package/dist/{content-block-CakKeJtN.mjs.map → content-block-CDMrz41K.mjs.map} +1 -1
  63. package/dist/{content-block-CrekbIfe.js → content-block-DyYAnL2e.js} +2 -2
  64. package/dist/{content-block-CrekbIfe.js.map → content-block-DyYAnL2e.js.map} +1 -1
  65. package/dist/content-block.cjs.js +1 -1
  66. package/dist/content-block.es.js +1 -1
  67. package/dist/countdown-5Ni6OlVY.mjs +189 -0
  68. package/dist/countdown-5Ni6OlVY.mjs.map +1 -0
  69. package/dist/countdown-CGXJyzB2.js +2 -0
  70. package/dist/countdown-CGXJyzB2.js.map +1 -0
  71. package/dist/countdown.cjs.js +1 -1
  72. package/dist/countdown.es.js +1 -1
  73. package/dist/{dropdown-CMO_VD5e.mjs → dropdown-CDK_eRm3.mjs} +3 -3
  74. package/dist/{dropdown-CMO_VD5e.mjs.map → dropdown-CDK_eRm3.mjs.map} +1 -1
  75. package/dist/{dropdown-DJKNQnuo.js → dropdown-_FLHLyPL.js} +2 -2
  76. package/dist/{dropdown-DJKNQnuo.js.map → dropdown-_FLHLyPL.js.map} +1 -1
  77. package/dist/dropdown.cjs.js +1 -1
  78. package/dist/dropdown.es.js +1 -1
  79. package/dist/{footer-cet787Iq.js → footer-CS6ZfztM.js} +2 -2
  80. package/dist/{footer-cet787Iq.js.map → footer-CS6ZfztM.js.map} +1 -1
  81. package/dist/{footer-BMlXRro2.mjs → footer-OJXbTn1e.mjs} +2 -2
  82. package/dist/{footer-BMlXRro2.mjs.map → footer-OJXbTn1e.mjs.map} +1 -1
  83. package/dist/footer.cjs.js +1 -1
  84. package/dist/footer.es.js +1 -1
  85. package/dist/{hero-banner-D__doaU7.js → hero-banner--v-ezYMr.js} +2 -2
  86. package/dist/{hero-banner-D__doaU7.js.map → hero-banner--v-ezYMr.js.map} +1 -1
  87. package/dist/{hero-banner-B08jC0Sf.mjs → hero-banner-n9K-Jsdz.mjs} +2 -2
  88. package/dist/{hero-banner-B08jC0Sf.mjs.map → hero-banner-n9K-Jsdz.mjs.map} +1 -1
  89. package/dist/hero-banner.cjs.js +1 -1
  90. package/dist/hero-banner.es.js +1 -1
  91. package/dist/library.cjs.js +1 -1
  92. package/dist/library.es.js +28 -28
  93. package/dist/{listbox-i6BQQ-NZ.mjs → listbox-CtV-Vcmy.mjs} +2 -2
  94. package/dist/{listbox-i6BQQ-NZ.mjs.map → listbox-CtV-Vcmy.mjs.map} +1 -1
  95. package/dist/{listbox-ATP4hOWF.js → listbox-lXO21cJV.js} +2 -2
  96. package/dist/{listbox-ATP4hOWF.js.map → listbox-lXO21cJV.js.map} +1 -1
  97. package/dist/listbox.cjs.js +1 -1
  98. package/dist/listbox.es.js +1 -1
  99. package/dist/{loading-Dwtkjstg.js → loading-B_0NjCnh.js} +2 -2
  100. package/dist/{loading-Dwtkjstg.js.map → loading-B_0NjCnh.js.map} +1 -1
  101. package/dist/{loading-r23nxJSz.mjs → loading-DqZBpMaa.mjs} +2 -2
  102. package/dist/{loading-r23nxJSz.mjs.map → loading-DqZBpMaa.mjs.map} +1 -1
  103. package/dist/loading.cjs.js +1 -1
  104. package/dist/loading.es.js +1 -1
  105. package/dist/{message-D9CDwcw9.mjs → message-CeXuAhmb.mjs} +3 -3
  106. package/dist/{message-D9CDwcw9.mjs.map → message-CeXuAhmb.mjs.map} +1 -1
  107. package/dist/{message-0yTS5pOF.js → message-DsGB-JFh.js} +2 -2
  108. package/dist/{message-0yTS5pOF.js.map → message-DsGB-JFh.js.map} +1 -1
  109. package/dist/message.cjs.js +1 -1
  110. package/dist/message.es.js +1 -1
  111. package/dist/{modal-Evh8sCBO.mjs → modal-Bu1Zv5Ic.mjs} +2 -2
  112. package/dist/{modal-Evh8sCBO.mjs.map → modal-Bu1Zv5Ic.mjs.map} +1 -1
  113. package/dist/{modal-CmPPxJ7Y.js → modal-D0Qxrvx5.js} +2 -2
  114. package/dist/{modal-CmPPxJ7Y.js.map → modal-D0Qxrvx5.js.map} +1 -1
  115. package/dist/modal.cjs.js +1 -1
  116. package/dist/modal.es.js +1 -1
  117. package/dist/{notification-B5bNNq86.js → notification-D2oClkX2.js} +2 -2
  118. package/dist/{notification-B5bNNq86.js.map → notification-D2oClkX2.js.map} +1 -1
  119. package/dist/{notification-BbQCmsnY.mjs → notification-DiVdy6E_.mjs} +2 -2
  120. package/dist/{notification-BbQCmsnY.mjs.map → notification-DiVdy6E_.mjs.map} +1 -1
  121. package/dist/notification.cjs.js +1 -1
  122. package/dist/notification.es.js +1 -1
  123. package/dist/{pagination-rFRdkHII.js → pagination-BDfaybj3.js} +2 -2
  124. package/dist/{pagination-rFRdkHII.js.map → pagination-BDfaybj3.js.map} +1 -1
  125. package/dist/{pagination-Cc_4zCQA.mjs → pagination-Bm38GKga.mjs} +2 -2
  126. package/dist/{pagination-Cc_4zCQA.mjs.map → pagination-Bm38GKga.mjs.map} +1 -1
  127. package/dist/pagination.cjs.js +1 -1
  128. package/dist/pagination.es.js +1 -1
  129. package/dist/{paragraph-By4jMjnH.js → paragraph-B8HFdNne.js} +2 -2
  130. package/dist/{paragraph-By4jMjnH.js.map → paragraph-B8HFdNne.js.map} +1 -1
  131. package/dist/{paragraph-DSxXmX_0.mjs → paragraph-CwAdFoIm.mjs} +3 -3
  132. package/dist/{paragraph-DSxXmX_0.mjs.map → paragraph-CwAdFoIm.mjs.map} +1 -1
  133. package/dist/paragraph.cjs.js +1 -1
  134. package/dist/paragraph.es.js +1 -1
  135. package/dist/{popover-XJqF5DHT.js → popover-BFozkeS3.js} +2 -2
  136. package/dist/{popover-XJqF5DHT.js.map → popover-BFozkeS3.js.map} +1 -1
  137. package/dist/{popover-BSUdf0Ae.mjs → popover-DFPGkVJ6.mjs} +2 -2
  138. package/dist/{popover-BSUdf0Ae.mjs.map → popover-DFPGkVJ6.mjs.map} +1 -1
  139. package/dist/popover.cjs.js +1 -1
  140. package/dist/popover.es.js +1 -1
  141. package/dist/{product-card-Bt-F0wKr.mjs → product-card-CxfHfJVV.mjs} +3 -3
  142. package/dist/{product-card-Bt-F0wKr.mjs.map → product-card-CxfHfJVV.mjs.map} +1 -1
  143. package/dist/{product-card-8X-Ld2d_.js → product-card-XxBwuxM-.js} +2 -2
  144. package/dist/{product-card-8X-Ld2d_.js.map → product-card-XxBwuxM-.js.map} +1 -1
  145. package/dist/product-card.cjs.js +1 -1
  146. package/dist/product-card.es.js +1 -1
  147. package/dist/{promotion-card-BnXD2mkp.js → promotion-card-C1UoxzcV.js} +2 -2
  148. package/dist/{promotion-card-BnXD2mkp.js.map → promotion-card-C1UoxzcV.js.map} +1 -1
  149. package/dist/{promotion-card-DOO0VCI8.mjs → promotion-card-CooYPpFo.mjs} +37 -37
  150. package/dist/{promotion-card-DOO0VCI8.mjs.map → promotion-card-CooYPpFo.mjs.map} +1 -1
  151. package/dist/promotion-card.cjs.js +1 -1
  152. package/dist/promotion-card.es.js +1 -1
  153. package/dist/purpur.css +1 -1
  154. package/dist/{radio-card-group-nrDi5EPK.js → radio-card-group-BXwkIIEw.js} +2 -2
  155. package/dist/{radio-card-group-nrDi5EPK.js.map → radio-card-group-BXwkIIEw.js.map} +1 -1
  156. package/dist/{radio-card-group-ZBXjYcQs.mjs → radio-card-group-Bn6SK0Wc.mjs} +2 -2
  157. package/dist/{radio-card-group-ZBXjYcQs.mjs.map → radio-card-group-Bn6SK0Wc.mjs.map} +1 -1
  158. package/dist/radio-card-group.cjs.js +1 -1
  159. package/dist/radio-card-group.es.js +1 -1
  160. package/dist/rich-text.cjs.js +1 -1
  161. package/dist/rich-text.es.js +1 -1
  162. package/dist/{search-field-_h8xn-sj.mjs → search-field-BPLzy3RR.mjs} +2 -2
  163. package/dist/{search-field-_h8xn-sj.mjs.map → search-field-BPLzy3RR.mjs.map} +1 -1
  164. package/dist/{search-field-vh6uz5KV.js → search-field-Dx4qCcrh.js} +2 -2
  165. package/dist/{search-field-vh6uz5KV.js.map → search-field-Dx4qCcrh.js.map} +1 -1
  166. package/dist/search-field.cjs.js +1 -1
  167. package/dist/search-field.es.js +1 -1
  168. package/dist/{stepper-B-nCLs2D.mjs → stepper-DSl-YCMe.mjs} +2 -2
  169. package/dist/{stepper-B-nCLs2D.mjs.map → stepper-DSl-YCMe.mjs.map} +1 -1
  170. package/dist/{stepper-CTKlnH0q.js → stepper-eaxkBC7o.js} +2 -2
  171. package/dist/{stepper-CTKlnH0q.js.map → stepper-eaxkBC7o.js.map} +1 -1
  172. package/dist/stepper.cjs.js +1 -1
  173. package/dist/stepper.es.js +1 -1
  174. package/dist/{table-DOPXfD-s.mjs → table-D9MKkbPO.mjs} +5 -5
  175. package/dist/{table-DOPXfD-s.mjs.map → table-D9MKkbPO.mjs.map} +1 -1
  176. package/dist/{table-DTQe4nN8.js → table-rS3hITtj.js} +2 -2
  177. package/dist/{table-DTQe4nN8.js.map → table-rS3hITtj.js.map} +1 -1
  178. package/dist/table.cjs.js +1 -1
  179. package/dist/table.es.js +1 -1
  180. package/dist/{toggle-B8ZLUVar.js → toggle-BgrfdtmN.js} +2 -2
  181. package/dist/{toggle-B8ZLUVar.js.map → toggle-BgrfdtmN.js.map} +1 -1
  182. package/dist/{toggle-CY3J8BRX.mjs → toggle-Cg1KFa_2.mjs} +2 -2
  183. package/dist/{toggle-CY3J8BRX.mjs.map → toggle-Cg1KFa_2.mjs.map} +1 -1
  184. package/dist/toggle.cjs.js +1 -1
  185. package/dist/toggle.es.js +1 -1
  186. package/dist/{tooltip-CDnJKoIA.js → tooltip-B-11qk-0.js} +2 -2
  187. package/dist/{tooltip-CDnJKoIA.js.map → tooltip-B-11qk-0.js.map} +1 -1
  188. package/dist/{tooltip-pwJMEBBP.mjs → tooltip-DngYHn5W.mjs} +2 -2
  189. package/dist/{tooltip-pwJMEBBP.mjs.map → tooltip-DngYHn5W.mjs.map} +1 -1
  190. package/dist/tooltip.cjs.js +1 -1
  191. package/dist/tooltip.es.js +1 -1
  192. package/package.json +25 -25
  193. package/dist/avatar-CYnD57o4.js +0 -2
  194. package/dist/avatar-CYnD57o4.js.map +0 -1
  195. package/dist/avatar-CzbDD1MK.mjs +0 -27
  196. package/dist/avatar-CzbDD1MK.mjs.map +0 -1
  197. package/dist/comparison-table-0UDB2BTU.js +0 -2
  198. package/dist/comparison-table-0UDB2BTU.js.map +0 -1
  199. package/dist/comparison-table-CjTE-fHN.mjs +0 -292
  200. package/dist/comparison-table-CjTE-fHN.mjs.map +0 -1
  201. package/dist/countdown-BsLsEZBv.mjs +0 -179
  202. package/dist/countdown-BsLsEZBv.mjs.map +0 -1
  203. package/dist/countdown-hYrFLmRg.js +0 -2
  204. package/dist/countdown-hYrFLmRg.js.map +0 -1
package/dist/table.cjs.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./table-DTQe4nN8.js");exports.Table=e.Table;exports.createColumnHelper=e.createColumnHelper;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./table-rS3hITtj.js");exports.Table=e.Table;exports.createColumnHelper=e.createColumnHelper;
2
2
  //# sourceMappingURL=table.cjs.js.map
package/dist/table.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { T as r, c as l } from "./table-DOPXfD-s.mjs";
1
+ import { T as r, c as l } from "./table-D9MKkbPO.mjs";
2
2
  export {
3
3
  r as Table,
4
4
  l as createColumnHelper
@@ -1,2 +1,2 @@
1
- "use strict";const v=require("react/jsx-runtime"),n=require("react"),O=require("./icon.es-j3eRib6d.js"),H=require("./checkmark-bold.es-DdJFVVJG.js"),T=require("./label-yHK80hhV.js"),W=require("./paragraph-By4jMjnH.js"),E=require("./index-CxBG4Ssm.js"),A=require("./index-_XxjJPRD.js"),I=require("./index-kcwFA4Dv.js"),F=require("./index-DOFLOnao.js"),M=require("./index-Hk_HrrHM.js"),U=require("./bind-DeUYJ6m9.js");function V(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const D=V(n);var j="Switch",[G]=I.createContextScope(j),[J,K]=G(j),$=D.forwardRef((e,r)=>{const{__scopeSwitch:t,name:o,checked:a,defaultChecked:c,required:p,disabled:g,value:s="on",onCheckedChange:i,form:_,...f}=e,[l,u]=D.useState(null),d=A.useComposedRefs(r,k=>u(k)),b=D.useRef(!1),m=l?_||!!l.closest("form"):!0,[h=!1,x]=E.useControllableState({prop:a,defaultProp:c,onChange:i});return v.jsxs(J,{scope:t,checked:h,disabled:g,children:[v.jsx(M.Primitive.button,{type:"button",role:"switch","aria-checked":h,"aria-required":p,"data-state":L(h),"data-disabled":g?"":void 0,disabled:g,value:s,...f,ref:d,onClick:E.composeEventHandlers(e.onClick,k=>{x(w=>!w),m&&(b.current=k.isPropagationStopped(),b.current||k.stopPropagation())})}),m&&v.jsx(Q,{control:l,bubbles:!b.current,name:o,value:s,checked:h,required:p,disabled:g,form:_,style:{transform:"translateX(-100%)"}})]})});$.displayName=j;var q="SwitchThumb",N=D.forwardRef((e,r)=>{const{__scopeSwitch:t,...o}=e,a=K(q,t);return v.jsx(M.Primitive.span,{"data-state":L(a.checked),"data-disabled":a.disabled?"":void 0,...o,ref:r})});N.displayName=q;var Q=e=>{const{control:r,checked:t,bubbles:o=!0,...a}=e,c=D.useRef(null),p=E.usePrevious(t),g=F.useSize(r);return D.useEffect(()=>{const s=c.current,i=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(i,"checked").set;if(p!==t&&f){const l=new Event("click",{bubbles:o});f.call(s,t),s.dispatchEvent(l)}},[p,t,o]),v.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:t,...a,tabIndex:-1,ref:c,style:{...e.style,...g,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function L(e){return e?"checked":"unchecked"}var Y=$,Z=N;const z=e=>e&&"touches"in e,ee=({children:e,disabled:r,onStart:t,onDrag:o,onStop:a,bounds:c,position:p,style:g})=>{const[s,i]=n.useState(void 0),[_,f]=n.useState(void 0),[l,u]=n.useState(!1),d=h=>{if(!r){h.preventDefault();const x=z(h.nativeEvent)?h.nativeEvent.touches[0].clientX:h.nativeEvent.clientX;f(x),t?.()}},b=n.useCallback(h=>{if(typeof _!="number")return;const k=(z(h)?h.touches[0].clientX:h.clientX)-_;if(!k)return;const w=p+k;!l&&Math.abs(w)&&u(!0);const R=w>c.right?c.right:w<c.left?c.left:w;i(R),o?.({x:R})},[o,i,l,_]),m=n.useCallback(()=>{f(void 0),i(void 0),u(!1),a?.()},[a,f]);return n.useEffect(()=>(window.addEventListener("mousemove",b),window.addEventListener("touchmove",b),()=>{window.removeEventListener("mousemove",b),window.removeEventListener("touchmove",b)}),[b]),n.useEffect(()=>(window.addEventListener("mouseup",m),window.addEventListener("touchend",m),()=>{window.removeEventListener("mouseup",m),window.removeEventListener("touchend",m)}),[m]),n.isValidElement(e)?n.cloneElement(e,{onMouseDown:d,onTouchStart:d,style:{...g,transform:`translateX(${l?s:p}px)`}}):null},X={width:void 0,height:void 0};function P(e){const{ref:r,box:t="content-box",round:o}=e,[{width:a,height:c},p]=n.useState(X),g=te(),s=n.useRef({...X}),i=n.useRef(void 0);return i.current=e.onResize,n.useEffect(()=>{if(!r.current||typeof window>"u"||!("ResizeObserver"in window))return;const _=new ResizeObserver(([f])=>{const l=t==="border-box"?"borderBoxSize":t==="device-pixel-content-box"?"devicePixelContentBoxSize":"contentBoxSize",u=y(f,l,"inlineSize"),d=y(f,l,"blockSize");if(s.current.width!==u||s.current.height!==d){const m={width:u&&o?Math.round(u):u,height:d&&o?Math.round(d):d};s.current.width=u,s.current.height=d,i.current?i.current(m):g()&&p(m)}});return _.observe(r.current,{box:t}),()=>{_.disconnect()}},[t,r,g,o]),{width:a,height:c}}function y(e,r,t){return e[r]?Array.isArray(e[r])?e[r][0][t]:e[r][t]:r==="contentBoxSize"?e.contentRect[t==="inlineSize"?"width":"height"]:void 0}function te(){const e=n.useRef(!1);return n.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),n.useCallback(()=>e.current,[])}const re=({checked:e,onChange:r})=>{const t=n.useRef(null),o=n.useRef(null),[a,c]=n.useState(void 0),[p,g]=n.useState(!1),[s,i]=n.useState(0),{height:_=0}=P({ref:o,round:!0}),{height:f=0}=P({ref:t,round:!0}),l=(f||0)-_,u=_+l,d=l/2,b=u/2,m=typeof a=="number"&&(e?a<b:a>b);return{trackRef:t,thumbRef:o,isDragging:p,bounds:{left:d,right:u},position:e?u:d,onDrag:({x:w})=>{c(w),Math.abs((e?u:d)-w)>2&&g(!0)},onStop:()=>{g(!1),p&&i(Date.now()),m&&r?.(!e)},onChangeWithDrag:()=>{Date.now()-s>50&&r?.(!e),c(void 0)}}},ne={"purpur-toggle":"_purpur-toggle_15s9r_1","purpur-toggle__track":"_purpur-toggle__track_15s9r_7","purpur-toggle__checkmark-container":"_purpur-toggle__checkmark-container_15s9r_45","purpur-toggle__track--negative":"_purpur-toggle__track--negative_15s9r_60","purpur-toggle__thumb":"_purpur-toggle__thumb_15s9r_64","purpur-toggle__thumb--dragging":"_purpur-toggle__thumb--dragging_15s9r_89","purpur-toggle__thumb--negative":"_purpur-toggle__thumb--negative_15s9r_98","purpur-toggle__checkmark":"_purpur-toggle__checkmark_15s9r_45","purpur-toggle__label--right":"_purpur-toggle__label--right_15s9r_126","purpur-toggle__label--left":"_purpur-toggle__label--left_15s9r_129","purpur-toggle__container":"_purpur-toggle__container_15s9r_132","purpur-toggle--negative":"_purpur-toggle--negative_15s9r_141"},C=U.c.bind(ne),S="purpur-toggle",B=n.forwardRef(({["data-testid"]:e,className:r,label:t,onChange:o,labelPosition:a="right",checked:c,disableDrag:p,defaultChecked:g,negative:s=!1,...i},_)=>{const[f,l]=n.useState(typeof c=="boolean"?c:!!g),u=!!(typeof c=="boolean"?c:f),{thumbRef:d,trackRef:b,isDragging:m,onChangeWithDrag:h,...x}=re({checked:u,onChange:w=>{i.disabled||(o?.(w),l(w))}}),k=()=>v.jsx(T.Label,{htmlFor:i.id,"data-testid":e&&`${e}-label`,disabled:i.disabled,className:C(`${S}__label`,`${S}__label--${a}`),negative:s,children:v.jsx(W.Paragraph,{disabled:i.disabled,negative:s,children:t})});return v.jsxs("div",{className:C(r,`${S}__container`),children:[t&&a==="left"&&k(),v.jsx(Y,{...i,ref:_,id:i.id,"data-testid":e,className:C(S,{[`${S}--negative`]:s}),onCheckedChange:h,checked:u,children:v.jsxs("span",{ref:b,className:C(`${S}__track`,{[`${S}__track--negative`]:s}),children:[v.jsx("span",{className:C(`${S}__checkmark-container`),children:v.jsx(O.b,{className:C(`${S}__checkmark`),svg:H.l,size:"xxs"})}),v.jsx(ee,{disabled:p,...x,children:v.jsx(Z,{ref:d,"data-testid":e&&`${e}-thumb`,className:C(`${S}__thumb`,{[`${S}__thumb--dragging`]:m,[`${S}__thumb--negative`]:s})})})]})}),t&&a==="right"&&k()]})});B.displayName="Toggle";exports.Toggle=B;
2
- //# sourceMappingURL=toggle-B8ZLUVar.js.map
1
+ "use strict";const v=require("react/jsx-runtime"),n=require("react"),O=require("./icon.es-j3eRib6d.js"),H=require("./checkmark-bold.es-DdJFVVJG.js"),T=require("./label-yHK80hhV.js"),W=require("./paragraph-B8HFdNne.js"),E=require("./index-CxBG4Ssm.js"),A=require("./index-_XxjJPRD.js"),I=require("./index-kcwFA4Dv.js"),F=require("./index-DOFLOnao.js"),M=require("./index-Hk_HrrHM.js"),U=require("./bind-DeUYJ6m9.js");function V(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const D=V(n);var j="Switch",[G]=I.createContextScope(j),[J,K]=G(j),$=D.forwardRef((e,r)=>{const{__scopeSwitch:t,name:o,checked:a,defaultChecked:c,required:p,disabled:g,value:s="on",onCheckedChange:i,form:_,...f}=e,[l,u]=D.useState(null),d=A.useComposedRefs(r,k=>u(k)),b=D.useRef(!1),m=l?_||!!l.closest("form"):!0,[h=!1,x]=E.useControllableState({prop:a,defaultProp:c,onChange:i});return v.jsxs(J,{scope:t,checked:h,disabled:g,children:[v.jsx(M.Primitive.button,{type:"button",role:"switch","aria-checked":h,"aria-required":p,"data-state":L(h),"data-disabled":g?"":void 0,disabled:g,value:s,...f,ref:d,onClick:E.composeEventHandlers(e.onClick,k=>{x(w=>!w),m&&(b.current=k.isPropagationStopped(),b.current||k.stopPropagation())})}),m&&v.jsx(Q,{control:l,bubbles:!b.current,name:o,value:s,checked:h,required:p,disabled:g,form:_,style:{transform:"translateX(-100%)"}})]})});$.displayName=j;var q="SwitchThumb",N=D.forwardRef((e,r)=>{const{__scopeSwitch:t,...o}=e,a=K(q,t);return v.jsx(M.Primitive.span,{"data-state":L(a.checked),"data-disabled":a.disabled?"":void 0,...o,ref:r})});N.displayName=q;var Q=e=>{const{control:r,checked:t,bubbles:o=!0,...a}=e,c=D.useRef(null),p=E.usePrevious(t),g=F.useSize(r);return D.useEffect(()=>{const s=c.current,i=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(i,"checked").set;if(p!==t&&f){const l=new Event("click",{bubbles:o});f.call(s,t),s.dispatchEvent(l)}},[p,t,o]),v.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:t,...a,tabIndex:-1,ref:c,style:{...e.style,...g,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function L(e){return e?"checked":"unchecked"}var Y=$,Z=N;const z=e=>e&&"touches"in e,ee=({children:e,disabled:r,onStart:t,onDrag:o,onStop:a,bounds:c,position:p,style:g})=>{const[s,i]=n.useState(void 0),[_,f]=n.useState(void 0),[l,u]=n.useState(!1),d=h=>{if(!r){h.preventDefault();const x=z(h.nativeEvent)?h.nativeEvent.touches[0].clientX:h.nativeEvent.clientX;f(x),t?.()}},b=n.useCallback(h=>{if(typeof _!="number")return;const k=(z(h)?h.touches[0].clientX:h.clientX)-_;if(!k)return;const w=p+k;!l&&Math.abs(w)&&u(!0);const R=w>c.right?c.right:w<c.left?c.left:w;i(R),o?.({x:R})},[o,i,l,_]),m=n.useCallback(()=>{f(void 0),i(void 0),u(!1),a?.()},[a,f]);return n.useEffect(()=>(window.addEventListener("mousemove",b),window.addEventListener("touchmove",b),()=>{window.removeEventListener("mousemove",b),window.removeEventListener("touchmove",b)}),[b]),n.useEffect(()=>(window.addEventListener("mouseup",m),window.addEventListener("touchend",m),()=>{window.removeEventListener("mouseup",m),window.removeEventListener("touchend",m)}),[m]),n.isValidElement(e)?n.cloneElement(e,{onMouseDown:d,onTouchStart:d,style:{...g,transform:`translateX(${l?s:p}px)`}}):null},X={width:void 0,height:void 0};function P(e){const{ref:r,box:t="content-box",round:o}=e,[{width:a,height:c},p]=n.useState(X),g=te(),s=n.useRef({...X}),i=n.useRef(void 0);return i.current=e.onResize,n.useEffect(()=>{if(!r.current||typeof window>"u"||!("ResizeObserver"in window))return;const _=new ResizeObserver(([f])=>{const l=t==="border-box"?"borderBoxSize":t==="device-pixel-content-box"?"devicePixelContentBoxSize":"contentBoxSize",u=y(f,l,"inlineSize"),d=y(f,l,"blockSize");if(s.current.width!==u||s.current.height!==d){const m={width:u&&o?Math.round(u):u,height:d&&o?Math.round(d):d};s.current.width=u,s.current.height=d,i.current?i.current(m):g()&&p(m)}});return _.observe(r.current,{box:t}),()=>{_.disconnect()}},[t,r,g,o]),{width:a,height:c}}function y(e,r,t){return e[r]?Array.isArray(e[r])?e[r][0][t]:e[r][t]:r==="contentBoxSize"?e.contentRect[t==="inlineSize"?"width":"height"]:void 0}function te(){const e=n.useRef(!1);return n.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),n.useCallback(()=>e.current,[])}const re=({checked:e,onChange:r})=>{const t=n.useRef(null),o=n.useRef(null),[a,c]=n.useState(void 0),[p,g]=n.useState(!1),[s,i]=n.useState(0),{height:_=0}=P({ref:o,round:!0}),{height:f=0}=P({ref:t,round:!0}),l=(f||0)-_,u=_+l,d=l/2,b=u/2,m=typeof a=="number"&&(e?a<b:a>b);return{trackRef:t,thumbRef:o,isDragging:p,bounds:{left:d,right:u},position:e?u:d,onDrag:({x:w})=>{c(w),Math.abs((e?u:d)-w)>2&&g(!0)},onStop:()=>{g(!1),p&&i(Date.now()),m&&r?.(!e)},onChangeWithDrag:()=>{Date.now()-s>50&&r?.(!e),c(void 0)}}},ne={"purpur-toggle":"_purpur-toggle_15s9r_1","purpur-toggle__track":"_purpur-toggle__track_15s9r_7","purpur-toggle__checkmark-container":"_purpur-toggle__checkmark-container_15s9r_45","purpur-toggle__track--negative":"_purpur-toggle__track--negative_15s9r_60","purpur-toggle__thumb":"_purpur-toggle__thumb_15s9r_64","purpur-toggle__thumb--dragging":"_purpur-toggle__thumb--dragging_15s9r_89","purpur-toggle__thumb--negative":"_purpur-toggle__thumb--negative_15s9r_98","purpur-toggle__checkmark":"_purpur-toggle__checkmark_15s9r_45","purpur-toggle__label--right":"_purpur-toggle__label--right_15s9r_126","purpur-toggle__label--left":"_purpur-toggle__label--left_15s9r_129","purpur-toggle__container":"_purpur-toggle__container_15s9r_132","purpur-toggle--negative":"_purpur-toggle--negative_15s9r_141"},C=U.c.bind(ne),S="purpur-toggle",B=n.forwardRef(({["data-testid"]:e,className:r,label:t,onChange:o,labelPosition:a="right",checked:c,disableDrag:p,defaultChecked:g,negative:s=!1,...i},_)=>{const[f,l]=n.useState(typeof c=="boolean"?c:!!g),u=!!(typeof c=="boolean"?c:f),{thumbRef:d,trackRef:b,isDragging:m,onChangeWithDrag:h,...x}=re({checked:u,onChange:w=>{i.disabled||(o?.(w),l(w))}}),k=()=>v.jsx(T.Label,{htmlFor:i.id,"data-testid":e&&`${e}-label`,disabled:i.disabled,className:C(`${S}__label`,`${S}__label--${a}`),negative:s,children:v.jsx(W.Paragraph,{disabled:i.disabled,negative:s,children:t})});return v.jsxs("div",{className:C(r,`${S}__container`),children:[t&&a==="left"&&k(),v.jsx(Y,{...i,ref:_,id:i.id,"data-testid":e,className:C(S,{[`${S}--negative`]:s}),onCheckedChange:h,checked:u,children:v.jsxs("span",{ref:b,className:C(`${S}__track`,{[`${S}__track--negative`]:s}),children:[v.jsx("span",{className:C(`${S}__checkmark-container`),children:v.jsx(O.b,{className:C(`${S}__checkmark`),svg:H.l,size:"xxs"})}),v.jsx(ee,{disabled:p,...x,children:v.jsx(Z,{ref:d,"data-testid":e&&`${e}-thumb`,className:C(`${S}__thumb`,{[`${S}__thumb--dragging`]:m,[`${S}__thumb--negative`]:s})})})]})}),t&&a==="right"&&k()]})});B.displayName="Toggle";exports.Toggle=B;
2
+ //# sourceMappingURL=toggle-BgrfdtmN.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"toggle-B8ZLUVar.js","sources":["../../../common/temp/node_modules/.pnpm/@radix-ui+react-switch@1.1.4_@types+react-dom@19.2.3_@types+react@19.2.14__@types+react_7c6a1205dfc0b547da67f2d77f280718/node_modules/@radix-ui/react-switch/dist/index.mjs","../../../components/toggle/src/DraggableX.tsx","../../../components/toggle/src/hooks/useResizeObserver.ts","../../../components/toggle/src/hooks/useToggleDrag.ts","../../../components/toggle/src/toggle.tsx"],"sourcesContent":["\"use client\";\n\n// packages/react/switch/src/switch.tsx\nimport * as React from \"react\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { createContextScope } from \"@radix-ui/react-context\";\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport { usePrevious } from \"@radix-ui/react-use-previous\";\nimport { useSize } from \"@radix-ui/react-use-size\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { jsx, jsxs } from \"react/jsx-runtime\";\nvar SWITCH_NAME = \"Switch\";\nvar [createSwitchContext, createSwitchScope] = createContextScope(SWITCH_NAME);\nvar [SwitchProvider, useSwitchContext] = createSwitchContext(SWITCH_NAME);\nvar Switch = React.forwardRef(\n (props, forwardedRef) => {\n const {\n __scopeSwitch,\n name,\n checked: checkedProp,\n defaultChecked,\n required,\n disabled,\n value = \"on\",\n onCheckedChange,\n form,\n ...switchProps\n } = props;\n const [button, setButton] = React.useState(null);\n const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n const isFormControl = button ? form || !!button.closest(\"form\") : true;\n const [checked = false, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked,\n onChange: onCheckedChange\n });\n return /* @__PURE__ */ jsxs(SwitchProvider, { scope: __scopeSwitch, checked, disabled, children: [\n /* @__PURE__ */ jsx(\n Primitive.button,\n {\n type: \"button\",\n role: \"switch\",\n \"aria-checked\": checked,\n \"aria-required\": required,\n \"data-state\": getState(checked),\n \"data-disabled\": disabled ? \"\" : void 0,\n disabled,\n value,\n ...switchProps,\n ref: composedRefs,\n onClick: composeEventHandlers(props.onClick, (event) => {\n setChecked((prevChecked) => !prevChecked);\n if (isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })\n }\n ),\n isFormControl && /* @__PURE__ */ jsx(\n BubbleInput,\n {\n control: button,\n bubbles: !hasConsumerStoppedPropagationRef.current,\n name,\n value,\n checked,\n required,\n disabled,\n form,\n style: { transform: \"translateX(-100%)\" }\n }\n )\n ] });\n }\n);\nSwitch.displayName = SWITCH_NAME;\nvar THUMB_NAME = \"SwitchThumb\";\nvar SwitchThumb = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopeSwitch, ...thumbProps } = props;\n const context = useSwitchContext(THUMB_NAME, __scopeSwitch);\n return /* @__PURE__ */ jsx(\n Primitive.span,\n {\n \"data-state\": getState(context.checked),\n \"data-disabled\": context.disabled ? \"\" : void 0,\n ...thumbProps,\n ref: forwardedRef\n }\n );\n }\n);\nSwitchThumb.displayName = THUMB_NAME;\nvar BubbleInput = (props) => {\n const { control, checked, bubbles = true, ...inputProps } = props;\n const ref = React.useRef(null);\n const prevChecked = usePrevious(checked);\n const controlSize = useSize(control);\n React.useEffect(() => {\n const input = ref.current;\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(inputProto, \"checked\");\n const setChecked = descriptor.set;\n if (prevChecked !== checked && setChecked) {\n const event = new Event(\"click\", { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n }\n }, [prevChecked, checked, bubbles]);\n return /* @__PURE__ */ jsx(\n \"input\",\n {\n type: \"checkbox\",\n \"aria-hidden\": true,\n defaultChecked: checked,\n ...inputProps,\n tabIndex: -1,\n ref,\n style: {\n ...props.style,\n ...controlSize,\n position: \"absolute\",\n pointerEvents: \"none\",\n opacity: 0,\n margin: 0\n }\n }\n );\n};\nfunction getState(checked) {\n return checked ? \"checked\" : \"unchecked\";\n}\nvar Root = Switch;\nvar Thumb = SwitchThumb;\nexport {\n Root,\n Switch,\n SwitchThumb,\n Thumb,\n createSwitchScope\n};\n//# sourceMappingURL=index.mjs.map\n","import {\n cloneElement,\n type CSSProperties,\n isValidElement,\n type ReactElement,\n useCallback,\n useEffect,\n useState,\n} from \"react\";\nimport { type SwitchThumbProps } from \"@radix-ui/react-switch\";\n\nexport type DraggableXProps = {\n children?: ReactElement<SwitchThumbProps>;\n disabled?: boolean;\n position: number;\n bounds: { left: number; right: number };\n onStart?: () => void;\n onDrag?: (args: { x: number }) => void;\n onStop?: () => void;\n style?: CSSProperties;\n};\n\nconst isTouchEvent = (e: MouseEvent | TouchEvent): e is TouchEvent => e && \"touches\" in e;\n\n/**\n * Bare minimum to make the toggle draggable.\n * It is created for usage in the toggle only but could easily be extracted and used elsewhere.\n *\n * It is called `DraggableX` since it's only for dragging along the x-axis.\n */\nexport const DraggableX = ({\n children,\n disabled,\n onStart,\n onDrag,\n onStop,\n bounds,\n position,\n style,\n}: DraggableXProps) => {\n const [dragX, setDragX] = useState<number | undefined>(undefined);\n const [dragStartX, setDragStartX] = useState<number | undefined>(undefined);\n const [isDragging, setIsDragging] = useState(false);\n\n const startDrag = (e: React.MouseEvent | React.TouchEvent) => {\n if (!disabled) {\n e.preventDefault();\n const clientX = isTouchEvent(e.nativeEvent)\n ? e.nativeEvent.touches[0].clientX\n : e.nativeEvent.clientX;\n setDragStartX(clientX);\n onStart?.();\n }\n };\n\n const onMouseMove = useCallback(\n (e: MouseEvent | TouchEvent) => {\n if (typeof dragStartX !== \"number\") {\n return;\n }\n\n const clientX = isTouchEvent(e) ? e.touches[0].clientX : e.clientX;\n const dragDelta = clientX - dragStartX;\n\n if (!dragDelta) {\n return;\n }\n\n const nextDragX = position + dragDelta;\n if (!isDragging && Math.abs(nextDragX)) {\n setIsDragging(true);\n }\n\n const nextDragXBounded = (() => {\n if (nextDragX > bounds.right) {\n return bounds.right;\n }\n\n if (nextDragX < bounds.left) {\n return bounds.left;\n }\n\n return nextDragX;\n })();\n\n setDragX(nextDragXBounded);\n onDrag?.({ x: nextDragXBounded });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [onDrag, setDragX, isDragging, dragStartX]\n );\n\n const onMouseUp = useCallback(() => {\n setDragStartX(undefined);\n setDragX(undefined);\n setIsDragging(false);\n onStop?.();\n }, [onStop, setDragStartX]);\n\n useEffect(() => {\n window.addEventListener(\"mousemove\", onMouseMove);\n window.addEventListener(\"touchmove\", onMouseMove);\n\n return () => {\n window.removeEventListener(\"mousemove\", onMouseMove);\n window.removeEventListener(\"touchmove\", onMouseMove);\n };\n }, [onMouseMove]);\n\n useEffect(() => {\n window.addEventListener(\"mouseup\", onMouseUp);\n window.addEventListener(\"touchend\", onMouseUp);\n\n return () => {\n window.removeEventListener(\"mouseup\", onMouseUp);\n window.removeEventListener(\"touchend\", onMouseUp);\n };\n }, [onMouseUp]);\n\n return isValidElement(children)\n ? cloneElement<SwitchThumbProps>(children, {\n onMouseDown: startDrag,\n onTouchStart: startDrag,\n style: { ...style, transform: `translateX(${isDragging ? dragX : position}px)` },\n })\n : null;\n};\n","import type { RefObject } from \"react\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\n// This hook is a clone of useResizeObserver in b2c-sales/hooks\n\ntype Size = {\n width: number | undefined;\n height: number | undefined;\n};\n\ntype UseResizeObserverOptions<T extends HTMLElement = HTMLElement> = {\n ref: RefObject<T | null>;\n onResize?: (size: Size) => void;\n box?: \"border-box\" | \"content-box\" | \"device-pixel-content-box\";\n round?: boolean;\n};\n\nconst initialSize: Size = {\n width: undefined,\n height: undefined,\n};\n\nexport function useResizeObserver<T extends HTMLElement = HTMLElement>(\n options: UseResizeObserverOptions<T>\n): Size {\n const { ref, box = \"content-box\", round } = options;\n const [{ width, height }, setSize] = useState<Size>(initialSize);\n const isMounted = useIsMounted();\n const previousSize = useRef<Size>({ ...initialSize });\n const onResize = useRef<((size: Size) => void) | undefined>(undefined);\n onResize.current = options.onResize;\n\n useEffect(() => {\n if (!ref.current) {\n return;\n }\n\n if (typeof window === \"undefined\" || !(\"ResizeObserver\" in window)) {\n return;\n }\n\n const observer = new ResizeObserver(([entry]) => {\n const boxProp =\n\n box === \"border-box\"\n ? \"borderBoxSize\"\n : box === \"device-pixel-content-box\"\n ? \"devicePixelContentBoxSize\"\n : \"contentBoxSize\";\n\n const newWidth = extractSize(entry, boxProp, \"inlineSize\");\n const newHeight = extractSize(entry, boxProp, \"blockSize\");\n\n const hasChanged =\n previousSize.current.width !== newWidth || previousSize.current.height !== newHeight;\n\n if (hasChanged) {\n const newSize: Size = {\n width: newWidth && round ? Math.round(newWidth) : newWidth,\n height: newHeight && round ? Math.round(newHeight) : newHeight,\n };\n previousSize.current.width = newWidth;\n previousSize.current.height = newHeight;\n\n if (onResize.current) {\n onResize.current(newSize);\n } else {\n if (isMounted()) {\n setSize(newSize);\n }\n }\n }\n });\n\n observer.observe(ref.current, { box });\n\n return () => {\n observer.disconnect();\n };\n }, [box, ref, isMounted, round]);\n\n return { width, height };\n}\n\ntype BoxSizesKey = keyof Pick<\n ResizeObserverEntry,\n \"borderBoxSize\" | \"contentBoxSize\" | \"devicePixelContentBoxSize\"\n>;\n\nfunction extractSize(\n entry: ResizeObserverEntry,\n box: BoxSizesKey,\n sizeType: keyof ResizeObserverSize\n): number | undefined {\n if (!entry[box]) {\n if (box === \"contentBoxSize\") {\n return entry.contentRect[sizeType === \"inlineSize\" ? \"width\" : \"height\"];\n }\n return undefined;\n }\n\n return Array.isArray(entry[box])\n ? entry[box][0][sizeType]\n : // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore Support Firefox's non-standard behavior\n (entry[box][sizeType] as number);\n}\n\nfunction useIsMounted() {\n const isMounted = useRef(false);\n\n useEffect(() => {\n isMounted.current = true;\n\n return () => {\n isMounted.current = false;\n };\n }, []);\n\n return useCallback(() => isMounted.current, []);\n}\n","import { type RefObject, useRef, useState } from \"react\";\n\nimport { useResizeObserver } from \"./useResizeObserver\";\n\ntype UseToggleDragProps = {\n checked: boolean;\n onChange: ((checked: boolean) => void) | undefined;\n};\n\nexport const useToggleDrag = ({ checked, onChange }: UseToggleDragProps) => {\n const trackRef: RefObject<HTMLDivElement | null> = useRef(null);\n const thumbRef = useRef<HTMLSpanElement>(null);\n const [dragX, setDragX] = useState<number | undefined>(undefined);\n const [isDragging, setIsDragging] = useState(false);\n const [dragStopped, setDragStopped] = useState(0);\n\n const { height: thumbHeight = 0 } = useResizeObserver({ ref: thumbRef, round: true });\n const { height: switchHeight = 0 } = useResizeObserver({ ref: trackRef, round: true });\n\n const switchThumbHeightDelta = (switchHeight || 0) - thumbHeight;\n const maxDragRange = thumbHeight + switchThumbHeightDelta;\n const minDragRange = switchThumbHeightDelta / 2;\n const halfMaxDragRange = maxDragRange / 2;\n const isDraggedHalfway =\n typeof dragX === \"number\" && (checked ? dragX < halfMaxDragRange : dragX > halfMaxDragRange);\n\n const onDrag = ({ x }: { x: number }) => {\n setDragX(x);\n const dragDelta = Math.abs((checked ? maxDragRange : minDragRange) - x);\n\n // Add a threshold here for then accidentally dragging when clicking/touching\n dragDelta > 2 && setIsDragging(true);\n };\n\n const onStop = () => {\n setIsDragging(false);\n isDragging && setDragStopped(Date.now());\n if (isDraggedHalfway) {\n onChange?.(!checked);\n }\n };\n\n const onChangeWithDrag = () => {\n if (Date.now() - dragStopped > 50) {\n onChange?.(!checked);\n }\n setDragX(undefined);\n };\n\n return {\n trackRef,\n thumbRef,\n isDragging,\n bounds: { left: minDragRange, right: maxDragRange },\n position: checked ? maxDragRange : minDragRange,\n onDrag,\n onStop,\n onChangeWithDrag,\n };\n};\n","import React, { forwardRef, useState } from \"react\";\nimport type { BaseProps } from \"@purpur/common-types\";\nimport { Icon } from \"@purpur/icon\";\nimport { checkmarkBold } from \"@purpur/icon/assets/checkmark-bold\";\nimport { Label } from \"@purpur/label\";\nimport { Paragraph } from \"@purpur/paragraph\";\nimport * as Switch from \"@radix-ui/react-switch\";\nimport c from \"classnames/bind\";\n\nimport { DraggableX } from \"./DraggableX\";\nimport { useToggleDrag } from \"./hooks/useToggleDrag\";\nimport styles from \"./toggle.module.scss\";\n\nexport type ToggleProps = Omit<BaseProps<\"button\">, \"onChange\" | \"children\" | \"id\"> & {\n /**\n * To use when no label is given.\n * */\n [\"aria-label\"]?: string;\n /**\n * To use with custom label (not recommended).\n * */\n [\"aria-labelledby\"]?: string;\n /**\n * The controlled state of the toggle. Must be used in conjunction with `onChange`.\n * */\n checked?: boolean;\n /**\n * The state of the toggle when it is initially rendered. Use when you do not need to control its state.\n * */\n defaultChecked?: boolean;\n /**\n * When `true`, prevents the user from interacting with the toggle.\n * */\n disabled?: boolean;\n /**\n * When `true`, the toggle isn't draggable.\n * */\n disableDrag?: boolean;\n /**\n * ID of the toggle.\n * */\n id: string;\n /**\n * The label of the toggle.\n * */\n label?: string;\n /**\n * Set to decide which side of the toggle the label should be rendered.\n * */\n labelPosition?: \"left\" | \"right\";\n /**\n * The name of the toggle. Submitted with its owning form as part of a name/value pair, when wrapped in a form.\n * */\n name?: string;\n /**\n * Event handler called when the toggle is toggled.\n * */\n onChange?: (checked: boolean) => void;\n /**\n * When `true`, indicates that the user must check the toggle before the owning form can be submitted..\n * */\n required?: boolean;\n /**\n * The value given as data when wrapped with a form and submitted with a name.\n * */\n value?: string;\n negative?: boolean;\n};\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-toggle\";\n\nexport const Toggle = forwardRef<HTMLButtonElement, ToggleProps>(\n (\n {\n [\"data-testid\"]: dataTestId,\n className,\n label,\n onChange,\n labelPosition = \"right\",\n checked,\n disableDrag,\n defaultChecked,\n negative = false,\n ...props\n },\n ref\n ) => {\n const [internalChecked, setInternalChecked] = useState(\n typeof checked === \"boolean\" ? checked : !!defaultChecked\n );\n const isChecked = Boolean(typeof checked === \"boolean\" ? checked : internalChecked);\n const { thumbRef, trackRef, isDragging, onChangeWithDrag, ...draggableXProps } = useToggleDrag({\n checked: isChecked,\n onChange: (value) => {\n if (!props.disabled) {\n onChange?.(value);\n setInternalChecked(value);\n }\n },\n });\n\n const renderLabel = () => (\n <Label\n htmlFor={props.id}\n data-testid={dataTestId && `${dataTestId}-label`}\n disabled={props.disabled}\n className={cx(`${rootClassName}__label`, `${rootClassName}__label--${labelPosition}`)}\n negative={negative}\n >\n <Paragraph disabled={props.disabled} negative={negative}>\n {label}\n </Paragraph>\n </Label>\n );\n\n return (\n <div className={cx(className, `${rootClassName}__container`)}>\n {label && labelPosition === \"left\" && renderLabel()}\n <Switch.Root\n {...props}\n ref={ref}\n id={props.id}\n data-testid={dataTestId}\n className={cx(rootClassName, { [`${rootClassName}--negative`]: negative })}\n onCheckedChange={onChangeWithDrag}\n checked={isChecked}\n >\n <span\n ref={trackRef}\n className={cx(`${rootClassName}__track`, {\n [`${rootClassName}__track--negative`]: negative,\n })}\n >\n <span className={cx(`${rootClassName}__checkmark-container`)}>\n <Icon className={cx(`${rootClassName}__checkmark`)} svg={checkmarkBold} size=\"xxs\" />\n </span>\n <DraggableX disabled={disableDrag} {...draggableXProps}>\n <Switch.Thumb\n ref={thumbRef}\n data-testid={dataTestId && `${dataTestId}-thumb`}\n className={cx(`${rootClassName}__thumb`, {\n [`${rootClassName}__thumb--dragging`]: isDragging,\n [`${rootClassName}__thumb--negative`]: negative,\n })}\n />\n </DraggableX>\n </span>\n </Switch.Root>\n {label && labelPosition === \"right\" && renderLabel()}\n </div>\n );\n }\n);\n\nToggle.displayName = \"Toggle\";\n"],"names":["SWITCH_NAME","createSwitchContext","createContextScope","SwitchProvider","useSwitchContext","Switch","React","props","forwardedRef","__scopeSwitch","name","checkedProp","defaultChecked","required","disabled","value","onCheckedChange","form","switchProps","button","setButton","composedRefs","useComposedRefs","node","hasConsumerStoppedPropagationRef","isFormControl","checked","setChecked","useControllableState","jsxs","jsx","Primitive","getState","composeEventHandlers","event","prevChecked","BubbleInput","THUMB_NAME","SwitchThumb","thumbProps","context","control","bubbles","inputProps","ref","usePrevious","controlSize","useSize","input","inputProto","Root","Thumb","isTouchEvent","DraggableX","children","onStart","onDrag","onStop","bounds","position","style","dragX","setDragX","useState","dragStartX","setDragStartX","isDragging","setIsDragging","startDrag","e","clientX","onMouseMove","useCallback","dragDelta","nextDragX","nextDragXBounded","onMouseUp","useEffect","isValidElement","cloneElement","initialSize","useResizeObserver","options","box","round","width","height","setSize","isMounted","useIsMounted","previousSize","useRef","onResize","observer","entry","boxProp","newWidth","extractSize","newHeight","newSize","sizeType","useToggleDrag","onChange","trackRef","thumbRef","dragStopped","setDragStopped","thumbHeight","switchHeight","switchThumbHeightDelta","maxDragRange","minDragRange","halfMaxDragRange","isDraggedHalfway","x","cx","c","styles","rootClassName","Toggle","forwardRef","dataTestId","className","label","labelPosition","disableDrag","negative","internalChecked","setInternalChecked","isChecked","onChangeWithDrag","draggableXProps","renderLabel","Label","Paragraph","Switch.Root","Icon","checkmarkBold","Switch.Thumb"],"mappings":"0rBAYA,IAAIA,EAAc,SACd,CAACC,CAAsC,EAAIC,EAAAA,mBAAmBF,CAAW,EACzE,CAACG,EAAgBC,CAAgB,EAAIH,EAAoBD,CAAW,EACpEK,EAASC,EAAM,WACjB,CAACC,EAAOC,IAAiB,CACvB,KAAM,CACJ,cAAAC,EACA,KAAAC,EACA,QAASC,EACT,eAAAC,EACA,SAAAC,EACA,SAAAC,EACA,MAAAC,EAAQ,KACR,gBAAAC,EACA,KAAAC,EACA,GAAGC,CACT,EAAQX,EACE,CAACY,EAAQC,CAAS,EAAId,EAAM,SAAS,IAAI,EACzCe,EAAeC,EAAAA,gBAAgBd,EAAee,GAASH,EAAUG,CAAI,CAAC,EACtEC,EAAmClB,EAAM,OAAO,EAAK,EACrDmB,EAAgBN,EAASF,GAAQ,CAAC,CAACE,EAAO,QAAQ,MAAM,EAAI,GAC5D,CAACO,EAAU,GAAOC,CAAU,EAAIC,EAAAA,qBAAqB,CACzD,KAAMjB,EACN,YAAaC,EACb,SAAUI,CAChB,CAAK,EACD,OAAuBa,EAAAA,KAAK1B,EAAgB,CAAE,MAAOM,EAAe,QAAAiB,EAAS,SAAAZ,EAAU,SAAU,CAC/EgB,EAAAA,IACdC,EAAAA,UAAU,OACV,CACE,KAAM,SACN,KAAM,SACN,eAAgBL,EAChB,gBAAiBb,EACjB,aAAcmB,EAASN,CAAO,EAC9B,gBAAiBZ,EAAW,GAAK,OACjC,SAAAA,EACA,MAAAC,EACA,GAAGG,EACH,IAAKG,EACL,QAASY,EAAAA,qBAAqB1B,EAAM,QAAU2B,GAAU,CACtDP,EAAYQ,GAAgB,CAACA,CAA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WY,EAAG,GAAGG,CAAa,UAAW,CACvC,CAAC,GAAGA,CAAa,mBAAmB,EAAGQ,CAAA,CACxC,EAED,SAAA,CAAAhG,EAAAA,IAAC,QAAK,UAAWqF,EAAG,GAAGG,CAAa,uBAAuB,EACzD,SAAAxF,EAAAA,IAAC0G,EAAAA,EAAA,CAAK,UAAWrB,EAAG,GAAGG,CAAa,aAAa,EAAG,IAAKmB,IAAe,KAAK,MAAM,CAAA,CACrF,EACA3G,EAAAA,IAACuB,GAAA,CAAW,SAAUwE,EAAc,GAAGM,EACrC,SAAArG,EAAAA,IAAC4G,EAAA,CACC,IAAKlC,EACL,cAAaiB,GAAc,GAAGA,CAAU,SACxC,UAAWN,EAAG,GAAGG,CAAa,UAAW,CACvC,CAAC,GAAGA,CAAa,mBAAmB,EAAGpD,EACvC,CAAC,GAAGoD,CAAa,mBAAmB,EAAGQ,CAAA,CACxC,CAAA,CAAA,CACH,CACF,CAAA,CAAA,CAAA,CACF,CAAA,EAEDH,GAASC,IAAkB,SAAWQ,EAAA,CAAY,EACrD,CAEJ,CACF,EAEAb,EAAO,YAAc","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"toggle-BgrfdtmN.js","sources":["../../../common/temp/node_modules/.pnpm/@radix-ui+react-switch@1.1.4_@types+react-dom@19.2.3_@types+react@19.2.14__@types+react_7c6a1205dfc0b547da67f2d77f280718/node_modules/@radix-ui/react-switch/dist/index.mjs","../../../components/toggle/src/DraggableX.tsx","../../../components/toggle/src/hooks/useResizeObserver.ts","../../../components/toggle/src/hooks/useToggleDrag.ts","../../../components/toggle/src/toggle.tsx"],"sourcesContent":["\"use client\";\n\n// packages/react/switch/src/switch.tsx\nimport * as React from \"react\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { createContextScope } from \"@radix-ui/react-context\";\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport { usePrevious } from \"@radix-ui/react-use-previous\";\nimport { useSize } from \"@radix-ui/react-use-size\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { jsx, jsxs } from \"react/jsx-runtime\";\nvar SWITCH_NAME = \"Switch\";\nvar [createSwitchContext, createSwitchScope] = createContextScope(SWITCH_NAME);\nvar [SwitchProvider, useSwitchContext] = createSwitchContext(SWITCH_NAME);\nvar Switch = React.forwardRef(\n (props, forwardedRef) => {\n const {\n __scopeSwitch,\n name,\n checked: checkedProp,\n defaultChecked,\n required,\n disabled,\n value = \"on\",\n onCheckedChange,\n form,\n ...switchProps\n } = props;\n const [button, setButton] = React.useState(null);\n const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n const isFormControl = button ? form || !!button.closest(\"form\") : true;\n const [checked = false, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked,\n onChange: onCheckedChange\n });\n return /* @__PURE__ */ jsxs(SwitchProvider, { scope: __scopeSwitch, checked, disabled, children: [\n /* @__PURE__ */ jsx(\n Primitive.button,\n {\n type: \"button\",\n role: \"switch\",\n \"aria-checked\": checked,\n \"aria-required\": required,\n \"data-state\": getState(checked),\n \"data-disabled\": disabled ? \"\" : void 0,\n disabled,\n value,\n ...switchProps,\n ref: composedRefs,\n onClick: composeEventHandlers(props.onClick, (event) => {\n setChecked((prevChecked) => !prevChecked);\n if (isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })\n }\n ),\n isFormControl && /* @__PURE__ */ jsx(\n BubbleInput,\n {\n control: button,\n bubbles: !hasConsumerStoppedPropagationRef.current,\n name,\n value,\n checked,\n required,\n disabled,\n form,\n style: { transform: \"translateX(-100%)\" }\n }\n )\n ] });\n }\n);\nSwitch.displayName = SWITCH_NAME;\nvar THUMB_NAME = \"SwitchThumb\";\nvar SwitchThumb = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopeSwitch, ...thumbProps } = props;\n const context = useSwitchContext(THUMB_NAME, __scopeSwitch);\n return /* @__PURE__ */ jsx(\n Primitive.span,\n {\n \"data-state\": getState(context.checked),\n \"data-disabled\": context.disabled ? \"\" : void 0,\n ...thumbProps,\n ref: forwardedRef\n }\n );\n }\n);\nSwitchThumb.displayName = THUMB_NAME;\nvar BubbleInput = (props) => {\n const { control, checked, bubbles = true, ...inputProps } = props;\n const ref = React.useRef(null);\n const prevChecked = usePrevious(checked);\n const controlSize = useSize(control);\n React.useEffect(() => {\n const input = ref.current;\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(inputProto, \"checked\");\n const setChecked = descriptor.set;\n if (prevChecked !== checked && setChecked) {\n const event = new Event(\"click\", { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n }\n }, [prevChecked, checked, bubbles]);\n return /* @__PURE__ */ jsx(\n \"input\",\n {\n type: \"checkbox\",\n \"aria-hidden\": true,\n defaultChecked: checked,\n ...inputProps,\n tabIndex: -1,\n ref,\n style: {\n ...props.style,\n ...controlSize,\n position: \"absolute\",\n pointerEvents: \"none\",\n opacity: 0,\n margin: 0\n }\n }\n );\n};\nfunction getState(checked) {\n return checked ? \"checked\" : \"unchecked\";\n}\nvar Root = Switch;\nvar Thumb = SwitchThumb;\nexport {\n Root,\n Switch,\n SwitchThumb,\n Thumb,\n createSwitchScope\n};\n//# sourceMappingURL=index.mjs.map\n","import {\n cloneElement,\n type CSSProperties,\n isValidElement,\n type ReactElement,\n useCallback,\n useEffect,\n useState,\n} from \"react\";\nimport { type SwitchThumbProps } from \"@radix-ui/react-switch\";\n\nexport type DraggableXProps = {\n children?: ReactElement<SwitchThumbProps>;\n disabled?: boolean;\n position: number;\n bounds: { left: number; right: number };\n onStart?: () => void;\n onDrag?: (args: { x: number }) => void;\n onStop?: () => void;\n style?: CSSProperties;\n};\n\nconst isTouchEvent = (e: MouseEvent | TouchEvent): e is TouchEvent => e && \"touches\" in e;\n\n/**\n * Bare minimum to make the toggle draggable.\n * It is created for usage in the toggle only but could easily be extracted and used elsewhere.\n *\n * It is called `DraggableX` since it's only for dragging along the x-axis.\n */\nexport const DraggableX = ({\n children,\n disabled,\n onStart,\n onDrag,\n onStop,\n bounds,\n position,\n style,\n}: DraggableXProps) => {\n const [dragX, setDragX] = useState<number | undefined>(undefined);\n const [dragStartX, setDragStartX] = useState<number | undefined>(undefined);\n const [isDragging, setIsDragging] = useState(false);\n\n const startDrag = (e: React.MouseEvent | React.TouchEvent) => {\n if (!disabled) {\n e.preventDefault();\n const clientX = isTouchEvent(e.nativeEvent)\n ? e.nativeEvent.touches[0].clientX\n : e.nativeEvent.clientX;\n setDragStartX(clientX);\n onStart?.();\n }\n };\n\n const onMouseMove = useCallback(\n (e: MouseEvent | TouchEvent) => {\n if (typeof dragStartX !== \"number\") {\n return;\n }\n\n const clientX = isTouchEvent(e) ? e.touches[0].clientX : e.clientX;\n const dragDelta = clientX - dragStartX;\n\n if (!dragDelta) {\n return;\n }\n\n const nextDragX = position + dragDelta;\n if (!isDragging && Math.abs(nextDragX)) {\n setIsDragging(true);\n }\n\n const nextDragXBounded = (() => {\n if (nextDragX > bounds.right) {\n return bounds.right;\n }\n\n if (nextDragX < bounds.left) {\n return bounds.left;\n }\n\n return nextDragX;\n })();\n\n setDragX(nextDragXBounded);\n onDrag?.({ x: nextDragXBounded });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [onDrag, setDragX, isDragging, dragStartX]\n );\n\n const onMouseUp = useCallback(() => {\n setDragStartX(undefined);\n setDragX(undefined);\n setIsDragging(false);\n onStop?.();\n }, [onStop, setDragStartX]);\n\n useEffect(() => {\n window.addEventListener(\"mousemove\", onMouseMove);\n window.addEventListener(\"touchmove\", onMouseMove);\n\n return () => {\n window.removeEventListener(\"mousemove\", onMouseMove);\n window.removeEventListener(\"touchmove\", onMouseMove);\n };\n }, [onMouseMove]);\n\n useEffect(() => {\n window.addEventListener(\"mouseup\", onMouseUp);\n window.addEventListener(\"touchend\", onMouseUp);\n\n return () => {\n window.removeEventListener(\"mouseup\", onMouseUp);\n window.removeEventListener(\"touchend\", onMouseUp);\n };\n }, [onMouseUp]);\n\n return isValidElement(children)\n ? cloneElement<SwitchThumbProps>(children, {\n onMouseDown: startDrag,\n onTouchStart: startDrag,\n style: { ...style, transform: `translateX(${isDragging ? dragX : position}px)` },\n })\n : null;\n};\n","import type { RefObject } from \"react\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\n// This hook is a clone of useResizeObserver in b2c-sales/hooks\n\ntype Size = {\n width: number | undefined;\n height: number | undefined;\n};\n\ntype UseResizeObserverOptions<T extends HTMLElement = HTMLElement> = {\n ref: RefObject<T | null>;\n onResize?: (size: Size) => void;\n box?: \"border-box\" | \"content-box\" | \"device-pixel-content-box\";\n round?: boolean;\n};\n\nconst initialSize: Size = {\n width: undefined,\n height: undefined,\n};\n\nexport function useResizeObserver<T extends HTMLElement = HTMLElement>(\n options: UseResizeObserverOptions<T>\n): Size {\n const { ref, box = \"content-box\", round } = options;\n const [{ width, height }, setSize] = useState<Size>(initialSize);\n const isMounted = useIsMounted();\n const previousSize = useRef<Size>({ ...initialSize });\n const onResize = useRef<((size: Size) => void) | undefined>(undefined);\n onResize.current = options.onResize;\n\n useEffect(() => {\n if (!ref.current) {\n return;\n }\n\n if (typeof window === \"undefined\" || !(\"ResizeObserver\" in window)) {\n return;\n }\n\n const observer = new ResizeObserver(([entry]) => {\n const boxProp =\n\n box === \"border-box\"\n ? \"borderBoxSize\"\n : box === \"device-pixel-content-box\"\n ? \"devicePixelContentBoxSize\"\n : \"contentBoxSize\";\n\n const newWidth = extractSize(entry, boxProp, \"inlineSize\");\n const newHeight = extractSize(entry, boxProp, \"blockSize\");\n\n const hasChanged =\n previousSize.current.width !== newWidth || previousSize.current.height !== newHeight;\n\n if (hasChanged) {\n const newSize: Size = {\n width: newWidth && round ? Math.round(newWidth) : newWidth,\n height: newHeight && round ? Math.round(newHeight) : newHeight,\n };\n previousSize.current.width = newWidth;\n previousSize.current.height = newHeight;\n\n if (onResize.current) {\n onResize.current(newSize);\n } else {\n if (isMounted()) {\n setSize(newSize);\n }\n }\n }\n });\n\n observer.observe(ref.current, { box });\n\n return () => {\n observer.disconnect();\n };\n }, [box, ref, isMounted, round]);\n\n return { width, height };\n}\n\ntype BoxSizesKey = keyof Pick<\n ResizeObserverEntry,\n \"borderBoxSize\" | \"contentBoxSize\" | \"devicePixelContentBoxSize\"\n>;\n\nfunction extractSize(\n entry: ResizeObserverEntry,\n box: BoxSizesKey,\n sizeType: keyof ResizeObserverSize\n): number | undefined {\n if (!entry[box]) {\n if (box === \"contentBoxSize\") {\n return entry.contentRect[sizeType === \"inlineSize\" ? \"width\" : \"height\"];\n }\n return undefined;\n }\n\n return Array.isArray(entry[box])\n ? entry[box][0][sizeType]\n : // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore Support Firefox's non-standard behavior\n (entry[box][sizeType] as number);\n}\n\nfunction useIsMounted() {\n const isMounted = useRef(false);\n\n useEffect(() => {\n isMounted.current = true;\n\n return () => {\n isMounted.current = false;\n };\n }, []);\n\n return useCallback(() => isMounted.current, []);\n}\n","import { type RefObject, useRef, useState } from \"react\";\n\nimport { useResizeObserver } from \"./useResizeObserver\";\n\ntype UseToggleDragProps = {\n checked: boolean;\n onChange: ((checked: boolean) => void) | undefined;\n};\n\nexport const useToggleDrag = ({ checked, onChange }: UseToggleDragProps) => {\n const trackRef: RefObject<HTMLDivElement | null> = useRef(null);\n const thumbRef = useRef<HTMLSpanElement>(null);\n const [dragX, setDragX] = useState<number | undefined>(undefined);\n const [isDragging, setIsDragging] = useState(false);\n const [dragStopped, setDragStopped] = useState(0);\n\n const { height: thumbHeight = 0 } = useResizeObserver({ ref: thumbRef, round: true });\n const { height: switchHeight = 0 } = useResizeObserver({ ref: trackRef, round: true });\n\n const switchThumbHeightDelta = (switchHeight || 0) - thumbHeight;\n const maxDragRange = thumbHeight + switchThumbHeightDelta;\n const minDragRange = switchThumbHeightDelta / 2;\n const halfMaxDragRange = maxDragRange / 2;\n const isDraggedHalfway =\n typeof dragX === \"number\" && (checked ? dragX < halfMaxDragRange : dragX > halfMaxDragRange);\n\n const onDrag = ({ x }: { x: number }) => {\n setDragX(x);\n const dragDelta = Math.abs((checked ? maxDragRange : minDragRange) - x);\n\n // Add a threshold here for then accidentally dragging when clicking/touching\n dragDelta > 2 && setIsDragging(true);\n };\n\n const onStop = () => {\n setIsDragging(false);\n isDragging && setDragStopped(Date.now());\n if (isDraggedHalfway) {\n onChange?.(!checked);\n }\n };\n\n const onChangeWithDrag = () => {\n if (Date.now() - dragStopped > 50) {\n onChange?.(!checked);\n }\n setDragX(undefined);\n };\n\n return {\n trackRef,\n thumbRef,\n isDragging,\n bounds: { left: minDragRange, right: maxDragRange },\n position: checked ? maxDragRange : minDragRange,\n onDrag,\n onStop,\n onChangeWithDrag,\n };\n};\n","import React, { forwardRef, useState } from \"react\";\nimport type { BaseProps } from \"@purpur/common-types\";\nimport { Icon } from \"@purpur/icon\";\nimport { checkmarkBold } from \"@purpur/icon/assets/checkmark-bold\";\nimport { Label } from \"@purpur/label\";\nimport { Paragraph } from \"@purpur/paragraph\";\nimport * as Switch from \"@radix-ui/react-switch\";\nimport c from \"classnames/bind\";\n\nimport { DraggableX } from \"./DraggableX\";\nimport { useToggleDrag } from \"./hooks/useToggleDrag\";\nimport styles from \"./toggle.module.scss\";\n\nexport type ToggleProps = Omit<BaseProps<\"button\">, \"onChange\" | \"children\" | \"id\"> & {\n /**\n * To use when no label is given.\n * */\n [\"aria-label\"]?: string;\n /**\n * To use with custom label (not recommended).\n * */\n [\"aria-labelledby\"]?: string;\n /**\n * The controlled state of the toggle. Must be used in conjunction with `onChange`.\n * */\n checked?: boolean;\n /**\n * The state of the toggle when it is initially rendered. Use when you do not need to control its state.\n * */\n defaultChecked?: boolean;\n /**\n * When `true`, prevents the user from interacting with the toggle.\n * */\n disabled?: boolean;\n /**\n * When `true`, the toggle isn't draggable.\n * */\n disableDrag?: boolean;\n /**\n * ID of the toggle.\n * */\n id: string;\n /**\n * The label of the toggle.\n * */\n label?: string;\n /**\n * Set to decide which side of the toggle the label should be rendered.\n * */\n labelPosition?: \"left\" | \"right\";\n /**\n * The name of the toggle. Submitted with its owning form as part of a name/value pair, when wrapped in a form.\n * */\n name?: string;\n /**\n * Event handler called when the toggle is toggled.\n * */\n onChange?: (checked: boolean) => void;\n /**\n * When `true`, indicates that the user must check the toggle before the owning form can be submitted..\n * */\n required?: boolean;\n /**\n * The value given as data when wrapped with a form and submitted with a name.\n * */\n value?: string;\n negative?: boolean;\n};\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-toggle\";\n\nexport const Toggle = forwardRef<HTMLButtonElement, ToggleProps>(\n (\n {\n [\"data-testid\"]: dataTestId,\n className,\n label,\n onChange,\n labelPosition = \"right\",\n checked,\n disableDrag,\n defaultChecked,\n negative = false,\n ...props\n },\n ref\n ) => {\n const [internalChecked, setInternalChecked] = useState(\n typeof checked === \"boolean\" ? checked : !!defaultChecked\n );\n const isChecked = Boolean(typeof checked === \"boolean\" ? checked : internalChecked);\n const { thumbRef, trackRef, isDragging, onChangeWithDrag, ...draggableXProps } = useToggleDrag({\n checked: isChecked,\n onChange: (value) => {\n if (!props.disabled) {\n onChange?.(value);\n setInternalChecked(value);\n }\n },\n });\n\n const renderLabel = () => (\n <Label\n htmlFor={props.id}\n data-testid={dataTestId && `${dataTestId}-label`}\n disabled={props.disabled}\n className={cx(`${rootClassName}__label`, `${rootClassName}__label--${labelPosition}`)}\n negative={negative}\n >\n <Paragraph disabled={props.disabled} negative={negative}>\n {label}\n </Paragraph>\n </Label>\n );\n\n return (\n <div className={cx(className, `${rootClassName}__container`)}>\n {label && labelPosition === \"left\" && renderLabel()}\n <Switch.Root\n {...props}\n ref={ref}\n id={props.id}\n data-testid={dataTestId}\n className={cx(rootClassName, { [`${rootClassName}--negative`]: negative })}\n onCheckedChange={onChangeWithDrag}\n checked={isChecked}\n >\n <span\n ref={trackRef}\n className={cx(`${rootClassName}__track`, {\n [`${rootClassName}__track--negative`]: negative,\n })}\n >\n <span className={cx(`${rootClassName}__checkmark-container`)}>\n <Icon className={cx(`${rootClassName}__checkmark`)} svg={checkmarkBold} size=\"xxs\" />\n </span>\n <DraggableX disabled={disableDrag} {...draggableXProps}>\n <Switch.Thumb\n ref={thumbRef}\n data-testid={dataTestId && `${dataTestId}-thumb`}\n className={cx(`${rootClassName}__thumb`, {\n [`${rootClassName}__thumb--dragging`]: isDragging,\n [`${rootClassName}__thumb--negative`]: negative,\n })}\n />\n </DraggableX>\n </span>\n </Switch.Root>\n {label && labelPosition === \"right\" && renderLabel()}\n </div>\n );\n }\n);\n\nToggle.displayName = \"Toggle\";\n"],"names":["SWITCH_NAME","createSwitchContext","createContextScope","SwitchProvider","useSwitchContext","Switch","React","props","forwardedRef","__scopeSwitch","name","checkedProp","defaultChecked","required","disabled","value","onCheckedChange","form","switchProps","button","setButton","composedRefs","useComposedRefs","node","hasConsumerStoppedPropagationRef","isFormControl","checked","setChecked","useControllableState","jsxs","jsx","Primitive","getState","composeEventHandlers","event","prevChecked","BubbleInput","THUMB_NAME","SwitchThumb","thumbProps","context","control","bubbles","inputProps","ref","usePrevious","controlSize","useSize","input","inputProto","Root","Thumb","isTouchEvent","DraggableX","children","onStart","onDrag","onStop","bounds","position","style","dragX","setDragX","useState","dragStartX","setDragStartX","isDragging","setIsDragging","startDrag","e","clientX","onMouseMove","useCallback","dragDelta","nextDragX","nextDragXBounded","onMouseUp","useEffect","isValidElement","cloneElement","initialSize","useResizeObserver","options","box","round","width","height","setSize","isMounted","useIsMounted","previousSize","useRef","onResize","observer","entry","boxProp","newWidth","extractSize","newHeight","newSize","sizeType","useToggleDrag","onChange","trackRef","thumbRef","dragStopped","setDragStopped","thumbHeight","switchHeight","switchThumbHeightDelta","maxDragRange","minDragRange","halfMaxDragRange","isDraggedHalfway","x","cx","c","styles","rootClassName","Toggle","forwardRef","dataTestId","className","label","labelPosition","disableDrag","negative","internalChecked","setInternalChecked","isChecked","onChangeWithDrag","draggableXProps","renderLabel","Label","Paragraph","Switch.Root","Icon","checkmarkBold","Switch.Thumb"],"mappings":"0rBAYA,IAAIA,EAAc,SACd,CAACC,CAAsC,EAAIC,EAAAA,mBAAmBF,CAAW,EACzE,CAACG,EAAgBC,CAAgB,EAAIH,EAAoBD,CAAW,EACpEK,EAASC,EAAM,WACjB,CAACC,EAAOC,IAAiB,CACvB,KAAM,CACJ,cAAAC,EACA,KAAAC,EACA,QAASC,EACT,eAAAC,EACA,SAAAC,EACA,SAAAC,EACA,MAAAC,EAAQ,KACR,gBAAAC,EACA,KAAAC,EACA,GAAGC,CACT,EAAQX,EACE,CAACY,EAAQC,CAAS,EAAId,EAAM,SAAS,IAAI,EACzCe,EAAeC,EAAAA,gBAAgBd,EAAee,GAASH,EAAUG,CAAI,CAAC,EACtEC,EAAmClB,EAAM,OAAO,EAAK,EACrDmB,EAAgBN,EAASF,GAAQ,CAAC,CAACE,EAAO,QAAQ,MAAM,EAAI,GAC5D,CAACO,EAAU,GAAOC,CAAU,EAAIC,EAAAA,qBAAqB,CACzD,KAAMjB,EACN,YAAaC,EACb,SAAUI,CAChB,CAAK,EACD,OAAuBa,EAAAA,KAAK1B,EAAgB,CAAE,MAAOM,EAAe,QAAAiB,EAAS,SAAAZ,EAAU,SAAU,CAC/EgB,EAAAA,IACdC,EAAAA,UAAU,OACV,CACE,KAAM,SACN,KAAM,SACN,eAAgBL,EAChB,gBAAiBb,EACjB,aAAcmB,EAASN,CAAO,EAC9B,gBAAiBZ,EAAW,GAAK,OACjC,SAAAA,EACA,MAAAC,EACA,GAAGG,EACH,IAAKG,EACL,QAASY,EAAAA,qBAAqB1B,EAAM,QAAU2B,GAAU,CACtDP,EAAYQ,GAAgB,CAACA,CAAW,EACpCV,IACFD,EAAiC,QAAUU,EAAM,qBAAoB,EAChEV,EAAiC,SAASU,EAAM,gBAAe,EAExE,CAAC,CACX,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AAAhG,EAAAA,IAAC,QAAK,UAAWqF,EAAG,GAAGG,CAAa,uBAAuB,EACzD,SAAAxF,EAAAA,IAAC0G,EAAAA,EAAA,CAAK,UAAWrB,EAAG,GAAGG,CAAa,aAAa,EAAG,IAAKmB,IAAe,KAAK,MAAM,CAAA,CACrF,EACA3G,EAAAA,IAACuB,GAAA,CAAW,SAAUwE,EAAc,GAAGM,EACrC,SAAArG,EAAAA,IAAC4G,EAAA,CACC,IAAKlC,EACL,cAAaiB,GAAc,GAAGA,CAAU,SACxC,UAAWN,EAAG,GAAGG,CAAa,UAAW,CACvC,CAAC,GAAGA,CAAa,mBAAmB,EAAGpD,EACvC,CAAC,GAAGoD,CAAa,mBAAmB,EAAGQ,CAAA,CACxC,CAAA,CAAA,CACH,CACF,CAAA,CAAA,CAAA,CACF,CAAA,EAEDH,GAASC,IAAkB,SAAWQ,EAAA,CAAY,EACrD,CAEJ,CACF,EAEAb,EAAO,YAAc","x_google_ignoreList":[0]}
@@ -4,7 +4,7 @@ import { useState as S, useCallback as P, useEffect as E, isValidElement as A, c
4
4
  import { b as q } from "./icon.es-CZcKxTaM.mjs";
5
5
  import { l as F } from "./checkmark-bold.es-CV3e_t3E.mjs";
6
6
  import { L as U } from "./label-7sJe5-pX.mjs";
7
- import { P as V } from "./paragraph-DSxXmX_0.mjs";
7
+ import { P as V } from "./paragraph-CwAdFoIm.mjs";
8
8
  import { u as G, c as J, a as K } from "./index-tyLV0iiH.mjs";
9
9
  import { u as Q } from "./index-DLcqcWxM.mjs";
10
10
  import { c as Y } from "./index-DOfn3ixy.mjs";
@@ -299,4 +299,4 @@ ge.displayName = "Toggle";
299
299
  export {
300
300
  ge as T
301
301
  };
302
- //# sourceMappingURL=toggle-CY3J8BRX.mjs.map
302
+ //# sourceMappingURL=toggle-Cg1KFa_2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"toggle-CY3J8BRX.mjs","sources":["../../../common/temp/node_modules/.pnpm/@radix-ui+react-switch@1.1.4_@types+react-dom@19.2.3_@types+react@19.2.14__@types+react_7c6a1205dfc0b547da67f2d77f280718/node_modules/@radix-ui/react-switch/dist/index.mjs","../../../components/toggle/src/DraggableX.tsx","../../../components/toggle/src/hooks/useResizeObserver.ts","../../../components/toggle/src/hooks/useToggleDrag.ts","../../../components/toggle/src/toggle.tsx"],"sourcesContent":["\"use client\";\n\n// packages/react/switch/src/switch.tsx\nimport * as React from \"react\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { createContextScope } from \"@radix-ui/react-context\";\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport { usePrevious } from \"@radix-ui/react-use-previous\";\nimport { useSize } from \"@radix-ui/react-use-size\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { jsx, jsxs } from \"react/jsx-runtime\";\nvar SWITCH_NAME = \"Switch\";\nvar [createSwitchContext, createSwitchScope] = createContextScope(SWITCH_NAME);\nvar [SwitchProvider, useSwitchContext] = createSwitchContext(SWITCH_NAME);\nvar Switch = React.forwardRef(\n (props, forwardedRef) => {\n const {\n __scopeSwitch,\n name,\n checked: checkedProp,\n defaultChecked,\n required,\n disabled,\n value = \"on\",\n onCheckedChange,\n form,\n ...switchProps\n } = props;\n const [button, setButton] = React.useState(null);\n const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n const isFormControl = button ? form || !!button.closest(\"form\") : true;\n const [checked = false, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked,\n onChange: onCheckedChange\n });\n return /* @__PURE__ */ jsxs(SwitchProvider, { scope: __scopeSwitch, checked, disabled, children: [\n /* @__PURE__ */ jsx(\n Primitive.button,\n {\n type: \"button\",\n role: \"switch\",\n \"aria-checked\": checked,\n \"aria-required\": required,\n \"data-state\": getState(checked),\n \"data-disabled\": disabled ? \"\" : void 0,\n disabled,\n value,\n ...switchProps,\n ref: composedRefs,\n onClick: composeEventHandlers(props.onClick, (event) => {\n setChecked((prevChecked) => !prevChecked);\n if (isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })\n }\n ),\n isFormControl && /* @__PURE__ */ jsx(\n BubbleInput,\n {\n control: button,\n bubbles: !hasConsumerStoppedPropagationRef.current,\n name,\n value,\n checked,\n required,\n disabled,\n form,\n style: { transform: \"translateX(-100%)\" }\n }\n )\n ] });\n }\n);\nSwitch.displayName = SWITCH_NAME;\nvar THUMB_NAME = \"SwitchThumb\";\nvar SwitchThumb = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopeSwitch, ...thumbProps } = props;\n const context = useSwitchContext(THUMB_NAME, __scopeSwitch);\n return /* @__PURE__ */ jsx(\n Primitive.span,\n {\n \"data-state\": getState(context.checked),\n \"data-disabled\": context.disabled ? \"\" : void 0,\n ...thumbProps,\n ref: forwardedRef\n }\n );\n }\n);\nSwitchThumb.displayName = THUMB_NAME;\nvar BubbleInput = (props) => {\n const { control, checked, bubbles = true, ...inputProps } = props;\n const ref = React.useRef(null);\n const prevChecked = usePrevious(checked);\n const controlSize = useSize(control);\n React.useEffect(() => {\n const input = ref.current;\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(inputProto, \"checked\");\n const setChecked = descriptor.set;\n if (prevChecked !== checked && setChecked) {\n const event = new Event(\"click\", { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n }\n }, [prevChecked, checked, bubbles]);\n return /* @__PURE__ */ jsx(\n \"input\",\n {\n type: \"checkbox\",\n \"aria-hidden\": true,\n defaultChecked: checked,\n ...inputProps,\n tabIndex: -1,\n ref,\n style: {\n ...props.style,\n ...controlSize,\n position: \"absolute\",\n pointerEvents: \"none\",\n opacity: 0,\n margin: 0\n }\n }\n );\n};\nfunction getState(checked) {\n return checked ? \"checked\" : \"unchecked\";\n}\nvar Root = Switch;\nvar Thumb = SwitchThumb;\nexport {\n Root,\n Switch,\n SwitchThumb,\n Thumb,\n createSwitchScope\n};\n//# sourceMappingURL=index.mjs.map\n","import {\n cloneElement,\n type CSSProperties,\n isValidElement,\n type ReactElement,\n useCallback,\n useEffect,\n useState,\n} from \"react\";\nimport { type SwitchThumbProps } from \"@radix-ui/react-switch\";\n\nexport type DraggableXProps = {\n children?: ReactElement<SwitchThumbProps>;\n disabled?: boolean;\n position: number;\n bounds: { left: number; right: number };\n onStart?: () => void;\n onDrag?: (args: { x: number }) => void;\n onStop?: () => void;\n style?: CSSProperties;\n};\n\nconst isTouchEvent = (e: MouseEvent | TouchEvent): e is TouchEvent => e && \"touches\" in e;\n\n/**\n * Bare minimum to make the toggle draggable.\n * It is created for usage in the toggle only but could easily be extracted and used elsewhere.\n *\n * It is called `DraggableX` since it's only for dragging along the x-axis.\n */\nexport const DraggableX = ({\n children,\n disabled,\n onStart,\n onDrag,\n onStop,\n bounds,\n position,\n style,\n}: DraggableXProps) => {\n const [dragX, setDragX] = useState<number | undefined>(undefined);\n const [dragStartX, setDragStartX] = useState<number | undefined>(undefined);\n const [isDragging, setIsDragging] = useState(false);\n\n const startDrag = (e: React.MouseEvent | React.TouchEvent) => {\n if (!disabled) {\n e.preventDefault();\n const clientX = isTouchEvent(e.nativeEvent)\n ? e.nativeEvent.touches[0].clientX\n : e.nativeEvent.clientX;\n setDragStartX(clientX);\n onStart?.();\n }\n };\n\n const onMouseMove = useCallback(\n (e: MouseEvent | TouchEvent) => {\n if (typeof dragStartX !== \"number\") {\n return;\n }\n\n const clientX = isTouchEvent(e) ? e.touches[0].clientX : e.clientX;\n const dragDelta = clientX - dragStartX;\n\n if (!dragDelta) {\n return;\n }\n\n const nextDragX = position + dragDelta;\n if (!isDragging && Math.abs(nextDragX)) {\n setIsDragging(true);\n }\n\n const nextDragXBounded = (() => {\n if (nextDragX > bounds.right) {\n return bounds.right;\n }\n\n if (nextDragX < bounds.left) {\n return bounds.left;\n }\n\n return nextDragX;\n })();\n\n setDragX(nextDragXBounded);\n onDrag?.({ x: nextDragXBounded });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [onDrag, setDragX, isDragging, dragStartX]\n );\n\n const onMouseUp = useCallback(() => {\n setDragStartX(undefined);\n setDragX(undefined);\n setIsDragging(false);\n onStop?.();\n }, [onStop, setDragStartX]);\n\n useEffect(() => {\n window.addEventListener(\"mousemove\", onMouseMove);\n window.addEventListener(\"touchmove\", onMouseMove);\n\n return () => {\n window.removeEventListener(\"mousemove\", onMouseMove);\n window.removeEventListener(\"touchmove\", onMouseMove);\n };\n }, [onMouseMove]);\n\n useEffect(() => {\n window.addEventListener(\"mouseup\", onMouseUp);\n window.addEventListener(\"touchend\", onMouseUp);\n\n return () => {\n window.removeEventListener(\"mouseup\", onMouseUp);\n window.removeEventListener(\"touchend\", onMouseUp);\n };\n }, [onMouseUp]);\n\n return isValidElement(children)\n ? cloneElement<SwitchThumbProps>(children, {\n onMouseDown: startDrag,\n onTouchStart: startDrag,\n style: { ...style, transform: `translateX(${isDragging ? dragX : position}px)` },\n })\n : null;\n};\n","import type { RefObject } from \"react\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\n// This hook is a clone of useResizeObserver in b2c-sales/hooks\n\ntype Size = {\n width: number | undefined;\n height: number | undefined;\n};\n\ntype UseResizeObserverOptions<T extends HTMLElement = HTMLElement> = {\n ref: RefObject<T | null>;\n onResize?: (size: Size) => void;\n box?: \"border-box\" | \"content-box\" | \"device-pixel-content-box\";\n round?: boolean;\n};\n\nconst initialSize: Size = {\n width: undefined,\n height: undefined,\n};\n\nexport function useResizeObserver<T extends HTMLElement = HTMLElement>(\n options: UseResizeObserverOptions<T>\n): Size {\n const { ref, box = \"content-box\", round } = options;\n const [{ width, height }, setSize] = useState<Size>(initialSize);\n const isMounted = useIsMounted();\n const previousSize = useRef<Size>({ ...initialSize });\n const onResize = useRef<((size: Size) => void) | undefined>(undefined);\n onResize.current = options.onResize;\n\n useEffect(() => {\n if (!ref.current) {\n return;\n }\n\n if (typeof window === \"undefined\" || !(\"ResizeObserver\" in window)) {\n return;\n }\n\n const observer = new ResizeObserver(([entry]) => {\n const boxProp =\n\n box === \"border-box\"\n ? \"borderBoxSize\"\n : box === \"device-pixel-content-box\"\n ? \"devicePixelContentBoxSize\"\n : \"contentBoxSize\";\n\n const newWidth = extractSize(entry, boxProp, \"inlineSize\");\n const newHeight = extractSize(entry, boxProp, \"blockSize\");\n\n const hasChanged =\n previousSize.current.width !== newWidth || previousSize.current.height !== newHeight;\n\n if (hasChanged) {\n const newSize: Size = {\n width: newWidth && round ? Math.round(newWidth) : newWidth,\n height: newHeight && round ? Math.round(newHeight) : newHeight,\n };\n previousSize.current.width = newWidth;\n previousSize.current.height = newHeight;\n\n if (onResize.current) {\n onResize.current(newSize);\n } else {\n if (isMounted()) {\n setSize(newSize);\n }\n }\n }\n });\n\n observer.observe(ref.current, { box });\n\n return () => {\n observer.disconnect();\n };\n }, [box, ref, isMounted, round]);\n\n return { width, height };\n}\n\ntype BoxSizesKey = keyof Pick<\n ResizeObserverEntry,\n \"borderBoxSize\" | \"contentBoxSize\" | \"devicePixelContentBoxSize\"\n>;\n\nfunction extractSize(\n entry: ResizeObserverEntry,\n box: BoxSizesKey,\n sizeType: keyof ResizeObserverSize\n): number | undefined {\n if (!entry[box]) {\n if (box === \"contentBoxSize\") {\n return entry.contentRect[sizeType === \"inlineSize\" ? \"width\" : \"height\"];\n }\n return undefined;\n }\n\n return Array.isArray(entry[box])\n ? entry[box][0][sizeType]\n : // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore Support Firefox's non-standard behavior\n (entry[box][sizeType] as number);\n}\n\nfunction useIsMounted() {\n const isMounted = useRef(false);\n\n useEffect(() => {\n isMounted.current = true;\n\n return () => {\n isMounted.current = false;\n };\n }, []);\n\n return useCallback(() => isMounted.current, []);\n}\n","import { type RefObject, useRef, useState } from \"react\";\n\nimport { useResizeObserver } from \"./useResizeObserver\";\n\ntype UseToggleDragProps = {\n checked: boolean;\n onChange: ((checked: boolean) => void) | undefined;\n};\n\nexport const useToggleDrag = ({ checked, onChange }: UseToggleDragProps) => {\n const trackRef: RefObject<HTMLDivElement | null> = useRef(null);\n const thumbRef = useRef<HTMLSpanElement>(null);\n const [dragX, setDragX] = useState<number | undefined>(undefined);\n const [isDragging, setIsDragging] = useState(false);\n const [dragStopped, setDragStopped] = useState(0);\n\n const { height: thumbHeight = 0 } = useResizeObserver({ ref: thumbRef, round: true });\n const { height: switchHeight = 0 } = useResizeObserver({ ref: trackRef, round: true });\n\n const switchThumbHeightDelta = (switchHeight || 0) - thumbHeight;\n const maxDragRange = thumbHeight + switchThumbHeightDelta;\n const minDragRange = switchThumbHeightDelta / 2;\n const halfMaxDragRange = maxDragRange / 2;\n const isDraggedHalfway =\n typeof dragX === \"number\" && (checked ? dragX < halfMaxDragRange : dragX > halfMaxDragRange);\n\n const onDrag = ({ x }: { x: number }) => {\n setDragX(x);\n const dragDelta = Math.abs((checked ? maxDragRange : minDragRange) - x);\n\n // Add a threshold here for then accidentally dragging when clicking/touching\n dragDelta > 2 && setIsDragging(true);\n };\n\n const onStop = () => {\n setIsDragging(false);\n isDragging && setDragStopped(Date.now());\n if (isDraggedHalfway) {\n onChange?.(!checked);\n }\n };\n\n const onChangeWithDrag = () => {\n if (Date.now() - dragStopped > 50) {\n onChange?.(!checked);\n }\n setDragX(undefined);\n };\n\n return {\n trackRef,\n thumbRef,\n isDragging,\n bounds: { left: minDragRange, right: maxDragRange },\n position: checked ? maxDragRange : minDragRange,\n onDrag,\n onStop,\n onChangeWithDrag,\n };\n};\n","import React, { forwardRef, useState } from \"react\";\nimport type { BaseProps } from \"@purpur/common-types\";\nimport { Icon } from \"@purpur/icon\";\nimport { checkmarkBold } from \"@purpur/icon/assets/checkmark-bold\";\nimport { Label } from \"@purpur/label\";\nimport { Paragraph } from \"@purpur/paragraph\";\nimport * as Switch from \"@radix-ui/react-switch\";\nimport c from \"classnames/bind\";\n\nimport { DraggableX } from \"./DraggableX\";\nimport { useToggleDrag } from \"./hooks/useToggleDrag\";\nimport styles from \"./toggle.module.scss\";\n\nexport type ToggleProps = Omit<BaseProps<\"button\">, \"onChange\" | \"children\" | \"id\"> & {\n /**\n * To use when no label is given.\n * */\n [\"aria-label\"]?: string;\n /**\n * To use with custom label (not recommended).\n * */\n [\"aria-labelledby\"]?: string;\n /**\n * The controlled state of the toggle. Must be used in conjunction with `onChange`.\n * */\n checked?: boolean;\n /**\n * The state of the toggle when it is initially rendered. Use when you do not need to control its state.\n * */\n defaultChecked?: boolean;\n /**\n * When `true`, prevents the user from interacting with the toggle.\n * */\n disabled?: boolean;\n /**\n * When `true`, the toggle isn't draggable.\n * */\n disableDrag?: boolean;\n /**\n * ID of the toggle.\n * */\n id: string;\n /**\n * The label of the toggle.\n * */\n label?: string;\n /**\n * Set to decide which side of the toggle the label should be rendered.\n * */\n labelPosition?: \"left\" | \"right\";\n /**\n * The name of the toggle. Submitted with its owning form as part of a name/value pair, when wrapped in a form.\n * */\n name?: string;\n /**\n * Event handler called when the toggle is toggled.\n * */\n onChange?: (checked: boolean) => void;\n /**\n * When `true`, indicates that the user must check the toggle before the owning form can be submitted..\n * */\n required?: boolean;\n /**\n * The value given as data when wrapped with a form and submitted with a name.\n * */\n value?: string;\n negative?: boolean;\n};\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-toggle\";\n\nexport const Toggle = forwardRef<HTMLButtonElement, ToggleProps>(\n (\n {\n [\"data-testid\"]: dataTestId,\n className,\n label,\n onChange,\n labelPosition = \"right\",\n checked,\n disableDrag,\n defaultChecked,\n negative = false,\n ...props\n },\n ref\n ) => {\n const [internalChecked, setInternalChecked] = useState(\n typeof checked === \"boolean\" ? checked : !!defaultChecked\n );\n const isChecked = Boolean(typeof checked === \"boolean\" ? checked : internalChecked);\n const { thumbRef, trackRef, isDragging, onChangeWithDrag, ...draggableXProps } = useToggleDrag({\n checked: isChecked,\n onChange: (value) => {\n if (!props.disabled) {\n onChange?.(value);\n setInternalChecked(value);\n }\n },\n });\n\n const renderLabel = () => (\n <Label\n htmlFor={props.id}\n data-testid={dataTestId && `${dataTestId}-label`}\n disabled={props.disabled}\n className={cx(`${rootClassName}__label`, `${rootClassName}__label--${labelPosition}`)}\n negative={negative}\n >\n <Paragraph disabled={props.disabled} negative={negative}>\n {label}\n </Paragraph>\n </Label>\n );\n\n return (\n <div className={cx(className, `${rootClassName}__container`)}>\n {label && labelPosition === \"left\" && renderLabel()}\n <Switch.Root\n {...props}\n ref={ref}\n id={props.id}\n data-testid={dataTestId}\n className={cx(rootClassName, { [`${rootClassName}--negative`]: negative })}\n onCheckedChange={onChangeWithDrag}\n checked={isChecked}\n >\n <span\n ref={trackRef}\n className={cx(`${rootClassName}__track`, {\n [`${rootClassName}__track--negative`]: negative,\n })}\n >\n <span className={cx(`${rootClassName}__checkmark-container`)}>\n <Icon className={cx(`${rootClassName}__checkmark`)} svg={checkmarkBold} size=\"xxs\" />\n </span>\n <DraggableX disabled={disableDrag} {...draggableXProps}>\n <Switch.Thumb\n ref={thumbRef}\n data-testid={dataTestId && `${dataTestId}-thumb`}\n className={cx(`${rootClassName}__thumb`, {\n [`${rootClassName}__thumb--dragging`]: isDragging,\n [`${rootClassName}__thumb--negative`]: negative,\n })}\n />\n </DraggableX>\n </span>\n </Switch.Root>\n {label && labelPosition === \"right\" && renderLabel()}\n </div>\n );\n }\n);\n\nToggle.displayName = \"Toggle\";\n"],"names":["SWITCH_NAME","createSwitchContext","createContextScope","SwitchProvider","useSwitchContext","Switch","React","props","forwardedRef","__scopeSwitch","name","checkedProp","defaultChecked","required","disabled","value","onCheckedChange","form","switchProps","button","setButton","composedRefs","useComposedRefs","node","hasConsumerStoppedPropagationRef","isFormControl","checked","setChecked","useControllableState","jsxs","jsx","Primitive","getState","composeEventHandlers","event","prevChecked","BubbleInput","THUMB_NAME","SwitchThumb","thumbProps","context","control","bubbles","inputProps","ref","usePrevious","controlSize","useSize","input","inputProto","Root","Thumb","isTouchEvent","DraggableX","children","onStart","onDrag","onStop","bounds","position","style","dragX","setDragX","useState","dragStartX","setDragStartX","isDragging","setIsDragging","startDrag","e","clientX","onMouseMove","useCallback","dragDelta","nextDragX","nextDragXBounded","onMouseUp","useEffect","isValidElement","cloneElement","initialSize","useResizeObserver","options","box","round","width","height","setSize","isMounted","useIsMounted","previousSize","useRef","onResize","observer","entry","boxProp","newWidth","extractSize","newHeight","newSize","sizeType","useToggleDrag","onChange","trackRef","thumbRef","dragStopped","setDragStopped","thumbHeight","switchHeight","switchThumbHeightDelta","maxDragRange","minDragRange","halfMaxDragRange","isDraggedHalfway","x","cx","c","styles","rootClassName","Toggle","forwardRef","dataTestId","className","label","labelPosition","disableDrag","negative","internalChecked","setInternalChecked","isChecked","onChangeWithDrag","draggableXProps","renderLabel","Label","Paragraph","Switch.Root","Icon","checkmarkBold","Switch.Thumb"],"mappings":";;;;;;;;;;;;;AAYA,IAAIA,IAAc,UACd,CAACC,EAAsC,IAAIC,EAAmBF,CAAW,GACzE,CAACG,IAAgBC,EAAgB,IAAIH,GAAoBD,CAAW,GACpEK,IAASC,EAAM;AAAA,EACjB,CAACC,GAAOC,MAAiB;AACvB,UAAM;AAAA,MACJ,eAAAC;AAAA,MACA,MAAAC;AAAA,MACA,SAASC;AAAA,MACT,gBAAAC;AAAA,MACA,UAAAC;AAAA,MACA,UAAAC;AAAA,MACA,OAAAC,IAAQ;AAAA,MACR,iBAAAC;AAAA,MACA,MAAAC;AAAA,MACA,GAAGC;AAAA,IACT,IAAQX,GACE,CAACY,GAAQC,CAAS,IAAId,EAAM,SAAS,IAAI,GACzCe,IAAeC,EAAgBd,GAAc,CAACe,MAASH,EAAUG,CAAI,CAAC,GACtEC,IAAmClB,EAAM,OAAO,EAAK,GACrDmB,IAAgBN,IAASF,KAAQ,CAAC,CAACE,EAAO,QAAQ,MAAM,IAAI,IAC5D,CAACO,IAAU,IAAOC,CAAU,IAAIC,EAAqB;AAAA,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AAA,gBAAApG;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,KAAK0E;AAAA,cACL,WAAWY,EAAG,GAAGG,CAAa,WAAW;AAAA,gBACvC,CAAC,GAAGA,CAAa,mBAAmB,GAAGQ;AAAA,cAAA,CACxC;AAAA,cAED,UAAA;AAAA,gBAAA,gBAAAhG,EAAC,UAAK,WAAWqF,EAAG,GAAGG,CAAa,uBAAuB,GACzD,UAAA,gBAAAxF,EAAC0G,GAAA,EAAK,WAAWrB,EAAG,GAAGG,CAAa,aAAa,GAAG,KAAKmB,GAAe,MAAK,OAAM,EAAA,CACrF;AAAA,gBACA,gBAAA3G,EAACuB,IAAA,EAAW,UAAUwE,GAAc,GAAGM,GACrC,UAAA,gBAAArG;AAAA,kBAAC4G;AAAAA,kBAAA;AAAA,oBACC,KAAKlC;AAAA,oBACL,eAAaiB,KAAc,GAAGA,CAAU;AAAA,oBACxC,WAAWN,EAAG,GAAGG,CAAa,WAAW;AAAA,sBACvC,CAAC,GAAGA,CAAa,mBAAmB,GAAGpD;AAAA,sBACvC,CAAC,GAAGoD,CAAa,mBAAmB,GAAGQ;AAAA,oBAAA,CACxC;AAAA,kBAAA;AAAA,gBAAA,EACH,CACF;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,MAEDH,KAASC,MAAkB,WAAWQ,EAAA;AAAA,IAAY,GACrD;AAAA,EAEJ;AACF;AAEAb,GAAO,cAAc;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"toggle-Cg1KFa_2.mjs","sources":["../../../common/temp/node_modules/.pnpm/@radix-ui+react-switch@1.1.4_@types+react-dom@19.2.3_@types+react@19.2.14__@types+react_7c6a1205dfc0b547da67f2d77f280718/node_modules/@radix-ui/react-switch/dist/index.mjs","../../../components/toggle/src/DraggableX.tsx","../../../components/toggle/src/hooks/useResizeObserver.ts","../../../components/toggle/src/hooks/useToggleDrag.ts","../../../components/toggle/src/toggle.tsx"],"sourcesContent":["\"use client\";\n\n// packages/react/switch/src/switch.tsx\nimport * as React from \"react\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { createContextScope } from \"@radix-ui/react-context\";\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport { usePrevious } from \"@radix-ui/react-use-previous\";\nimport { useSize } from \"@radix-ui/react-use-size\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { jsx, jsxs } from \"react/jsx-runtime\";\nvar SWITCH_NAME = \"Switch\";\nvar [createSwitchContext, createSwitchScope] = createContextScope(SWITCH_NAME);\nvar [SwitchProvider, useSwitchContext] = createSwitchContext(SWITCH_NAME);\nvar Switch = React.forwardRef(\n (props, forwardedRef) => {\n const {\n __scopeSwitch,\n name,\n checked: checkedProp,\n defaultChecked,\n required,\n disabled,\n value = \"on\",\n onCheckedChange,\n form,\n ...switchProps\n } = props;\n const [button, setButton] = React.useState(null);\n const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n const isFormControl = button ? form || !!button.closest(\"form\") : true;\n const [checked = false, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked,\n onChange: onCheckedChange\n });\n return /* @__PURE__ */ jsxs(SwitchProvider, { scope: __scopeSwitch, checked, disabled, children: [\n /* @__PURE__ */ jsx(\n Primitive.button,\n {\n type: \"button\",\n role: \"switch\",\n \"aria-checked\": checked,\n \"aria-required\": required,\n \"data-state\": getState(checked),\n \"data-disabled\": disabled ? \"\" : void 0,\n disabled,\n value,\n ...switchProps,\n ref: composedRefs,\n onClick: composeEventHandlers(props.onClick, (event) => {\n setChecked((prevChecked) => !prevChecked);\n if (isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })\n }\n ),\n isFormControl && /* @__PURE__ */ jsx(\n BubbleInput,\n {\n control: button,\n bubbles: !hasConsumerStoppedPropagationRef.current,\n name,\n value,\n checked,\n required,\n disabled,\n form,\n style: { transform: \"translateX(-100%)\" }\n }\n )\n ] });\n }\n);\nSwitch.displayName = SWITCH_NAME;\nvar THUMB_NAME = \"SwitchThumb\";\nvar SwitchThumb = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopeSwitch, ...thumbProps } = props;\n const context = useSwitchContext(THUMB_NAME, __scopeSwitch);\n return /* @__PURE__ */ jsx(\n Primitive.span,\n {\n \"data-state\": getState(context.checked),\n \"data-disabled\": context.disabled ? \"\" : void 0,\n ...thumbProps,\n ref: forwardedRef\n }\n );\n }\n);\nSwitchThumb.displayName = THUMB_NAME;\nvar BubbleInput = (props) => {\n const { control, checked, bubbles = true, ...inputProps } = props;\n const ref = React.useRef(null);\n const prevChecked = usePrevious(checked);\n const controlSize = useSize(control);\n React.useEffect(() => {\n const input = ref.current;\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(inputProto, \"checked\");\n const setChecked = descriptor.set;\n if (prevChecked !== checked && setChecked) {\n const event = new Event(\"click\", { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n }\n }, [prevChecked, checked, bubbles]);\n return /* @__PURE__ */ jsx(\n \"input\",\n {\n type: \"checkbox\",\n \"aria-hidden\": true,\n defaultChecked: checked,\n ...inputProps,\n tabIndex: -1,\n ref,\n style: {\n ...props.style,\n ...controlSize,\n position: \"absolute\",\n pointerEvents: \"none\",\n opacity: 0,\n margin: 0\n }\n }\n );\n};\nfunction getState(checked) {\n return checked ? \"checked\" : \"unchecked\";\n}\nvar Root = Switch;\nvar Thumb = SwitchThumb;\nexport {\n Root,\n Switch,\n SwitchThumb,\n Thumb,\n createSwitchScope\n};\n//# sourceMappingURL=index.mjs.map\n","import {\n cloneElement,\n type CSSProperties,\n isValidElement,\n type ReactElement,\n useCallback,\n useEffect,\n useState,\n} from \"react\";\nimport { type SwitchThumbProps } from \"@radix-ui/react-switch\";\n\nexport type DraggableXProps = {\n children?: ReactElement<SwitchThumbProps>;\n disabled?: boolean;\n position: number;\n bounds: { left: number; right: number };\n onStart?: () => void;\n onDrag?: (args: { x: number }) => void;\n onStop?: () => void;\n style?: CSSProperties;\n};\n\nconst isTouchEvent = (e: MouseEvent | TouchEvent): e is TouchEvent => e && \"touches\" in e;\n\n/**\n * Bare minimum to make the toggle draggable.\n * It is created for usage in the toggle only but could easily be extracted and used elsewhere.\n *\n * It is called `DraggableX` since it's only for dragging along the x-axis.\n */\nexport const DraggableX = ({\n children,\n disabled,\n onStart,\n onDrag,\n onStop,\n bounds,\n position,\n style,\n}: DraggableXProps) => {\n const [dragX, setDragX] = useState<number | undefined>(undefined);\n const [dragStartX, setDragStartX] = useState<number | undefined>(undefined);\n const [isDragging, setIsDragging] = useState(false);\n\n const startDrag = (e: React.MouseEvent | React.TouchEvent) => {\n if (!disabled) {\n e.preventDefault();\n const clientX = isTouchEvent(e.nativeEvent)\n ? e.nativeEvent.touches[0].clientX\n : e.nativeEvent.clientX;\n setDragStartX(clientX);\n onStart?.();\n }\n };\n\n const onMouseMove = useCallback(\n (e: MouseEvent | TouchEvent) => {\n if (typeof dragStartX !== \"number\") {\n return;\n }\n\n const clientX = isTouchEvent(e) ? e.touches[0].clientX : e.clientX;\n const dragDelta = clientX - dragStartX;\n\n if (!dragDelta) {\n return;\n }\n\n const nextDragX = position + dragDelta;\n if (!isDragging && Math.abs(nextDragX)) {\n setIsDragging(true);\n }\n\n const nextDragXBounded = (() => {\n if (nextDragX > bounds.right) {\n return bounds.right;\n }\n\n if (nextDragX < bounds.left) {\n return bounds.left;\n }\n\n return nextDragX;\n })();\n\n setDragX(nextDragXBounded);\n onDrag?.({ x: nextDragXBounded });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [onDrag, setDragX, isDragging, dragStartX]\n );\n\n const onMouseUp = useCallback(() => {\n setDragStartX(undefined);\n setDragX(undefined);\n setIsDragging(false);\n onStop?.();\n }, [onStop, setDragStartX]);\n\n useEffect(() => {\n window.addEventListener(\"mousemove\", onMouseMove);\n window.addEventListener(\"touchmove\", onMouseMove);\n\n return () => {\n window.removeEventListener(\"mousemove\", onMouseMove);\n window.removeEventListener(\"touchmove\", onMouseMove);\n };\n }, [onMouseMove]);\n\n useEffect(() => {\n window.addEventListener(\"mouseup\", onMouseUp);\n window.addEventListener(\"touchend\", onMouseUp);\n\n return () => {\n window.removeEventListener(\"mouseup\", onMouseUp);\n window.removeEventListener(\"touchend\", onMouseUp);\n };\n }, [onMouseUp]);\n\n return isValidElement(children)\n ? cloneElement<SwitchThumbProps>(children, {\n onMouseDown: startDrag,\n onTouchStart: startDrag,\n style: { ...style, transform: `translateX(${isDragging ? dragX : position}px)` },\n })\n : null;\n};\n","import type { RefObject } from \"react\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\n// This hook is a clone of useResizeObserver in b2c-sales/hooks\n\ntype Size = {\n width: number | undefined;\n height: number | undefined;\n};\n\ntype UseResizeObserverOptions<T extends HTMLElement = HTMLElement> = {\n ref: RefObject<T | null>;\n onResize?: (size: Size) => void;\n box?: \"border-box\" | \"content-box\" | \"device-pixel-content-box\";\n round?: boolean;\n};\n\nconst initialSize: Size = {\n width: undefined,\n height: undefined,\n};\n\nexport function useResizeObserver<T extends HTMLElement = HTMLElement>(\n options: UseResizeObserverOptions<T>\n): Size {\n const { ref, box = \"content-box\", round } = options;\n const [{ width, height }, setSize] = useState<Size>(initialSize);\n const isMounted = useIsMounted();\n const previousSize = useRef<Size>({ ...initialSize });\n const onResize = useRef<((size: Size) => void) | undefined>(undefined);\n onResize.current = options.onResize;\n\n useEffect(() => {\n if (!ref.current) {\n return;\n }\n\n if (typeof window === \"undefined\" || !(\"ResizeObserver\" in window)) {\n return;\n }\n\n const observer = new ResizeObserver(([entry]) => {\n const boxProp =\n\n box === \"border-box\"\n ? \"borderBoxSize\"\n : box === \"device-pixel-content-box\"\n ? \"devicePixelContentBoxSize\"\n : \"contentBoxSize\";\n\n const newWidth = extractSize(entry, boxProp, \"inlineSize\");\n const newHeight = extractSize(entry, boxProp, \"blockSize\");\n\n const hasChanged =\n previousSize.current.width !== newWidth || previousSize.current.height !== newHeight;\n\n if (hasChanged) {\n const newSize: Size = {\n width: newWidth && round ? Math.round(newWidth) : newWidth,\n height: newHeight && round ? Math.round(newHeight) : newHeight,\n };\n previousSize.current.width = newWidth;\n previousSize.current.height = newHeight;\n\n if (onResize.current) {\n onResize.current(newSize);\n } else {\n if (isMounted()) {\n setSize(newSize);\n }\n }\n }\n });\n\n observer.observe(ref.current, { box });\n\n return () => {\n observer.disconnect();\n };\n }, [box, ref, isMounted, round]);\n\n return { width, height };\n}\n\ntype BoxSizesKey = keyof Pick<\n ResizeObserverEntry,\n \"borderBoxSize\" | \"contentBoxSize\" | \"devicePixelContentBoxSize\"\n>;\n\nfunction extractSize(\n entry: ResizeObserverEntry,\n box: BoxSizesKey,\n sizeType: keyof ResizeObserverSize\n): number | undefined {\n if (!entry[box]) {\n if (box === \"contentBoxSize\") {\n return entry.contentRect[sizeType === \"inlineSize\" ? \"width\" : \"height\"];\n }\n return undefined;\n }\n\n return Array.isArray(entry[box])\n ? entry[box][0][sizeType]\n : // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore Support Firefox's non-standard behavior\n (entry[box][sizeType] as number);\n}\n\nfunction useIsMounted() {\n const isMounted = useRef(false);\n\n useEffect(() => {\n isMounted.current = true;\n\n return () => {\n isMounted.current = false;\n };\n }, []);\n\n return useCallback(() => isMounted.current, []);\n}\n","import { type RefObject, useRef, useState } from \"react\";\n\nimport { useResizeObserver } from \"./useResizeObserver\";\n\ntype UseToggleDragProps = {\n checked: boolean;\n onChange: ((checked: boolean) => void) | undefined;\n};\n\nexport const useToggleDrag = ({ checked, onChange }: UseToggleDragProps) => {\n const trackRef: RefObject<HTMLDivElement | null> = useRef(null);\n const thumbRef = useRef<HTMLSpanElement>(null);\n const [dragX, setDragX] = useState<number | undefined>(undefined);\n const [isDragging, setIsDragging] = useState(false);\n const [dragStopped, setDragStopped] = useState(0);\n\n const { height: thumbHeight = 0 } = useResizeObserver({ ref: thumbRef, round: true });\n const { height: switchHeight = 0 } = useResizeObserver({ ref: trackRef, round: true });\n\n const switchThumbHeightDelta = (switchHeight || 0) - thumbHeight;\n const maxDragRange = thumbHeight + switchThumbHeightDelta;\n const minDragRange = switchThumbHeightDelta / 2;\n const halfMaxDragRange = maxDragRange / 2;\n const isDraggedHalfway =\n typeof dragX === \"number\" && (checked ? dragX < halfMaxDragRange : dragX > halfMaxDragRange);\n\n const onDrag = ({ x }: { x: number }) => {\n setDragX(x);\n const dragDelta = Math.abs((checked ? maxDragRange : minDragRange) - x);\n\n // Add a threshold here for then accidentally dragging when clicking/touching\n dragDelta > 2 && setIsDragging(true);\n };\n\n const onStop = () => {\n setIsDragging(false);\n isDragging && setDragStopped(Date.now());\n if (isDraggedHalfway) {\n onChange?.(!checked);\n }\n };\n\n const onChangeWithDrag = () => {\n if (Date.now() - dragStopped > 50) {\n onChange?.(!checked);\n }\n setDragX(undefined);\n };\n\n return {\n trackRef,\n thumbRef,\n isDragging,\n bounds: { left: minDragRange, right: maxDragRange },\n position: checked ? maxDragRange : minDragRange,\n onDrag,\n onStop,\n onChangeWithDrag,\n };\n};\n","import React, { forwardRef, useState } from \"react\";\nimport type { BaseProps } from \"@purpur/common-types\";\nimport { Icon } from \"@purpur/icon\";\nimport { checkmarkBold } from \"@purpur/icon/assets/checkmark-bold\";\nimport { Label } from \"@purpur/label\";\nimport { Paragraph } from \"@purpur/paragraph\";\nimport * as Switch from \"@radix-ui/react-switch\";\nimport c from \"classnames/bind\";\n\nimport { DraggableX } from \"./DraggableX\";\nimport { useToggleDrag } from \"./hooks/useToggleDrag\";\nimport styles from \"./toggle.module.scss\";\n\nexport type ToggleProps = Omit<BaseProps<\"button\">, \"onChange\" | \"children\" | \"id\"> & {\n /**\n * To use when no label is given.\n * */\n [\"aria-label\"]?: string;\n /**\n * To use with custom label (not recommended).\n * */\n [\"aria-labelledby\"]?: string;\n /**\n * The controlled state of the toggle. Must be used in conjunction with `onChange`.\n * */\n checked?: boolean;\n /**\n * The state of the toggle when it is initially rendered. Use when you do not need to control its state.\n * */\n defaultChecked?: boolean;\n /**\n * When `true`, prevents the user from interacting with the toggle.\n * */\n disabled?: boolean;\n /**\n * When `true`, the toggle isn't draggable.\n * */\n disableDrag?: boolean;\n /**\n * ID of the toggle.\n * */\n id: string;\n /**\n * The label of the toggle.\n * */\n label?: string;\n /**\n * Set to decide which side of the toggle the label should be rendered.\n * */\n labelPosition?: \"left\" | \"right\";\n /**\n * The name of the toggle. Submitted with its owning form as part of a name/value pair, when wrapped in a form.\n * */\n name?: string;\n /**\n * Event handler called when the toggle is toggled.\n * */\n onChange?: (checked: boolean) => void;\n /**\n * When `true`, indicates that the user must check the toggle before the owning form can be submitted..\n * */\n required?: boolean;\n /**\n * The value given as data when wrapped with a form and submitted with a name.\n * */\n value?: string;\n negative?: boolean;\n};\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-toggle\";\n\nexport const Toggle = forwardRef<HTMLButtonElement, ToggleProps>(\n (\n {\n [\"data-testid\"]: dataTestId,\n className,\n label,\n onChange,\n labelPosition = \"right\",\n checked,\n disableDrag,\n defaultChecked,\n negative = false,\n ...props\n },\n ref\n ) => {\n const [internalChecked, setInternalChecked] = useState(\n typeof checked === \"boolean\" ? checked : !!defaultChecked\n );\n const isChecked = Boolean(typeof checked === \"boolean\" ? checked : internalChecked);\n const { thumbRef, trackRef, isDragging, onChangeWithDrag, ...draggableXProps } = useToggleDrag({\n checked: isChecked,\n onChange: (value) => {\n if (!props.disabled) {\n onChange?.(value);\n setInternalChecked(value);\n }\n },\n });\n\n const renderLabel = () => (\n <Label\n htmlFor={props.id}\n data-testid={dataTestId && `${dataTestId}-label`}\n disabled={props.disabled}\n className={cx(`${rootClassName}__label`, `${rootClassName}__label--${labelPosition}`)}\n negative={negative}\n >\n <Paragraph disabled={props.disabled} negative={negative}>\n {label}\n </Paragraph>\n </Label>\n );\n\n return (\n <div className={cx(className, `${rootClassName}__container`)}>\n {label && labelPosition === \"left\" && renderLabel()}\n <Switch.Root\n {...props}\n ref={ref}\n id={props.id}\n data-testid={dataTestId}\n className={cx(rootClassName, { [`${rootClassName}--negative`]: negative })}\n onCheckedChange={onChangeWithDrag}\n checked={isChecked}\n >\n <span\n ref={trackRef}\n className={cx(`${rootClassName}__track`, {\n [`${rootClassName}__track--negative`]: negative,\n })}\n >\n <span className={cx(`${rootClassName}__checkmark-container`)}>\n <Icon className={cx(`${rootClassName}__checkmark`)} svg={checkmarkBold} size=\"xxs\" />\n </span>\n <DraggableX disabled={disableDrag} {...draggableXProps}>\n <Switch.Thumb\n ref={thumbRef}\n data-testid={dataTestId && `${dataTestId}-thumb`}\n className={cx(`${rootClassName}__thumb`, {\n [`${rootClassName}__thumb--dragging`]: isDragging,\n [`${rootClassName}__thumb--negative`]: negative,\n })}\n />\n </DraggableX>\n </span>\n </Switch.Root>\n {label && labelPosition === \"right\" && renderLabel()}\n </div>\n );\n }\n);\n\nToggle.displayName = \"Toggle\";\n"],"names":["SWITCH_NAME","createSwitchContext","createContextScope","SwitchProvider","useSwitchContext","Switch","React","props","forwardedRef","__scopeSwitch","name","checkedProp","defaultChecked","required","disabled","value","onCheckedChange","form","switchProps","button","setButton","composedRefs","useComposedRefs","node","hasConsumerStoppedPropagationRef","isFormControl","checked","setChecked","useControllableState","jsxs","jsx","Primitive","getState","composeEventHandlers","event","prevChecked","BubbleInput","THUMB_NAME","SwitchThumb","thumbProps","context","control","bubbles","inputProps","ref","usePrevious","controlSize","useSize","input","inputProto","Root","Thumb","isTouchEvent","DraggableX","children","onStart","onDrag","onStop","bounds","position","style","dragX","setDragX","useState","dragStartX","setDragStartX","isDragging","setIsDragging","startDrag","e","clientX","onMouseMove","useCallback","dragDelta","nextDragX","nextDragXBounded","onMouseUp","useEffect","isValidElement","cloneElement","initialSize","useResizeObserver","options","box","round","width","height","setSize","isMounted","useIsMounted","previousSize","useRef","onResize","observer","entry","boxProp","newWidth","extractSize","newHeight","newSize","sizeType","useToggleDrag","onChange","trackRef","thumbRef","dragStopped","setDragStopped","thumbHeight","switchHeight","switchThumbHeightDelta","maxDragRange","minDragRange","halfMaxDragRange","isDraggedHalfway","x","cx","c","styles","rootClassName","Toggle","forwardRef","dataTestId","className","label","labelPosition","disableDrag","negative","internalChecked","setInternalChecked","isChecked","onChangeWithDrag","draggableXProps","renderLabel","Label","Paragraph","Switch.Root","Icon","checkmarkBold","Switch.Thumb"],"mappings":";;;;;;;;;;;;;AAYA,IAAIA,IAAc,UACd,CAACC,EAAsC,IAAIC,EAAmBF,CAAW,GACzE,CAACG,IAAgBC,EAAgB,IAAIH,GAAoBD,CAAW,GACpEK,IAASC,EAAM;AAAA,EACjB,CAACC,GAAOC,MAAiB;AACvB,UAAM;AAAA,MACJ,eAAAC;AAAA,MACA,MAAAC;AAAA,MACA,SAASC;AAAA,MACT,gBAAAC;AAAA,MACA,UAAAC;AAAA,MACA,UAAAC;AAAA,MACA,OAAAC,IAAQ;AAAA,MACR,iBAAAC;AAAA,MACA,MAAAC;AAAA,MACA,GAAGC;AAAA,IACT,IAAQX,GACE,CAACY,GAAQC,CAAS,IAAId,EAAM,SAAS,IAAI,GACzCe,IAAeC,EAAgBd,GAAc,CAACe,MAASH,EAAUG,CAAI,CAAC,GACtEC,IAAmClB,EAAM,OAAO,EAAK,GACrDmB,IAAgBN,IAASF,KAAQ,CAAC,CAACE,EAAO,QAAQ,MAAM,IAAI,IAC5D,CAACO,IAAU,IAAOC,CAAU,IAAIC,EAAqB;AAAA,MACzD,MAAMjB;AAAA,MACN,aAAaC;AAAA,MACb,UAAUI;AAAA,IAChB,CAAK;AACD,WAAuB,gBAAAa,EAAK1B,IAAgB,EAAE,OAAOM,GAAe,SAAAiB,GAAS,UAAAZ,GAAU,UAAU;AAAA,MAC/E,gBAAAgB;AAAA,QACdC,EAAU;AAAA,QACV;AAAA,UAC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WAAWqF,EAAG,GAAGG,CAAa,uBAAuB,GACzD,UAAA,gBAAAxF,EAAC0G,GAAA,EAAK,WAAWrB,EAAG,GAAGG,CAAa,aAAa,GAAG,KAAKmB,GAAe,MAAK,OAAM,EAAA,CACrF;AAAA,gBACA,gBAAA3G,EAACuB,IAAA,EAAW,UAAUwE,GAAc,GAAGM,GACrC,UAAA,gBAAArG;AAAA,kBAAC4G;AAAAA,kBAAA;AAAA,oBACC,KAAKlC;AAAA,oBACL,eAAaiB,KAAc,GAAGA,CAAU;AAAA,oBACxC,WAAWN,EAAG,GAAGG,CAAa,WAAW;AAAA,sBACvC,CAAC,GAAGA,CAAa,mBAAmB,GAAGpD;AAAA,sBACvC,CAAC,GAAGoD,CAAa,mBAAmB,GAAGQ;AAAA,oBAAA,CACxC;AAAA,kBAAA;AAAA,gBAAA,EACH,CACF;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,MAEDH,KAASC,MAAkB,WAAWQ,EAAA;AAAA,IAAY,GACrD;AAAA,EAEJ;AACF;AAEAb,GAAO,cAAc;","x_google_ignoreList":[0]}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./toggle-B8ZLUVar.js");exports.Toggle=e.Toggle;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./toggle-BgrfdtmN.js");exports.Toggle=e.Toggle;
2
2
  //# sourceMappingURL=toggle.cjs.js.map
package/dist/toggle.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { T as g } from "./toggle-CY3J8BRX.mjs";
1
+ import { T as g } from "./toggle-Cg1KFa_2.mjs";
2
2
  export {
3
3
  g as Toggle
4
4
  };
@@ -1,2 +1,2 @@
1
- "use strict";const p=require("react/jsx-runtime"),Y=require("react"),le=require("./button-DmybVApa.js"),at=require("./info.es-Br84jly5.js"),ue=require("./paragraph-By4jMjnH.js"),ct=require("./variables-BSBunpiY.js");require("./ThemeProvider-BJGm3zai.js");const lt=require("./useThemePortalContainer-CUcqV327.js"),he=require("react-dom"),T=require("./floating-ui.react-dom-Cc_YSprQ.js"),ut=require("./bind-DeUYJ6m9.js");function ve(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const s=ve(Y),dt=ve(he);function _(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o.defaultPrevented)return t?.(o)}}function de(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function me(...e){return t=>{let n=!1;const r=e.map(o=>{const i=de(o,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<r.length;o++){const i=r[o];typeof i=="function"?i():de(e[o],null)}}}}function S(...e){return s.useCallback(me(...e),e)}function ye(e,t=[]){let n=[];function r(i,a){const u=s.createContext(a),c=n.length;n=[...n,a];const l=f=>{const{scope:v,children:h,...m}=f,y=v?.[e]?.[c]||u,x=s.useMemo(()=>m,Object.values(m));return p.jsx(y.Provider,{value:x,children:h})};l.displayName=i+"Provider";function d(f,v){const h=v?.[e]?.[c]||u,m=s.useContext(h);if(m)return m;if(a!==void 0)return a;throw new Error(`\`${f}\` must be used within \`${i}\``)}return[l,d]}const o=()=>{const i=n.map(a=>s.createContext(a));return function(u){const c=u?.[e]||i;return s.useMemo(()=>({[`__scope${e}`]:{...u,[e]:c}}),[u,c])}};return o.scopeName=e,[r,pt(o,...t)]}function pt(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const a=r.reduce((u,{useScope:c,scopeName:l})=>{const f=c(i)[`__scope${l}`];return{...u,...f}},{});return s.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}var ge=s.forwardRef((e,t)=>{const{children:n,...r}=e,o=s.Children.toArray(n),i=o.find(ft);if(i){const a=i.props.children,u=o.map(c=>c===i?s.Children.count(a)>1?s.Children.only(null):s.isValidElement(a)?a.props.children:null:c);return p.jsx(X,{...r,ref:t,children:s.isValidElement(a)?s.cloneElement(a,void 0,u):null})}return p.jsx(X,{...r,ref:t,children:n})});ge.displayName="Slot";var X=s.forwardRef((e,t)=>{const{children:n,...r}=e;if(s.isValidElement(n)){const o=vt(n),i=ht(r,n.props);return n.type!==s.Fragment&&(i.ref=t?me(t,o):o),s.cloneElement(n,i)}return s.Children.count(n)>1?s.Children.only(null):null});X.displayName="SlotClone";var xe=({children:e})=>p.jsx(p.Fragment,{children:e});function ft(e){return s.isValidElement(e)&&e.type===xe}function ht(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...u)=>{i(...u),o(...u)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function vt(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var mt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],A=mt.reduce((e,t)=>{const n=s.forwardRef((r,o)=>{const{asChild:i,...a}=r,u=i?ge:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),p.jsx(u,{...a,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function yt(e,t){e&&dt.flushSync(()=>e.dispatchEvent(t))}function j(e){const t=s.useRef(e);return s.useEffect(()=>{t.current=e}),s.useMemo(()=>(...n)=>t.current?.(...n),[])}function gt(e,t=globalThis?.document){const n=j(e);s.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var xt="DismissableLayer",K="dismissableLayer.update",wt="dismissableLayer.pointerDownOutside",Pt="dismissableLayer.focusOutside",pe,we=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Pe=s.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:a,onDismiss:u,...c}=e,l=s.useContext(we),[d,f]=s.useState(null),v=d?.ownerDocument??globalThis?.document,[,h]=s.useState({}),m=S(t,g=>f(g)),y=Array.from(l.layers),[x]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),P=y.indexOf(x),w=d?y.indexOf(d):-1,C=l.layersWithOutsidePointerEventsDisabled.size>0,E=w>=P,b=bt(g=>{const R=g.target,$=[...l.branches].some(k=>k.contains(R));!E||$||(o?.(g),a?.(g),g.defaultPrevented||u?.())},v),O=Tt(g=>{const R=g.target;[...l.branches].some(k=>k.contains(R))||(i?.(g),a?.(g),g.defaultPrevented||u?.())},v);return gt(g=>{w===l.layers.size-1&&(r?.(g),!g.defaultPrevented&&u&&(g.preventDefault(),u()))},v),s.useEffect(()=>{if(d)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(pe=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(d)),l.layers.add(d),fe(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(v.body.style.pointerEvents=pe)}},[d,v,n,l]),s.useEffect(()=>()=>{d&&(l.layers.delete(d),l.layersWithOutsidePointerEventsDisabled.delete(d),fe())},[d,l]),s.useEffect(()=>{const g=()=>h({});return document.addEventListener(K,g),()=>document.removeEventListener(K,g)},[]),p.jsx(A.div,{...c,ref:m,style:{pointerEvents:C?E?"auto":"none":void 0,...e.style},onFocusCapture:_(e.onFocusCapture,O.onFocusCapture),onBlurCapture:_(e.onBlurCapture,O.onBlurCapture),onPointerDownCapture:_(e.onPointerDownCapture,b.onPointerDownCapture)})});Pe.displayName=xt;var Et="DismissableLayerBranch",Ct=s.forwardRef((e,t)=>{const n=s.useContext(we),r=s.useRef(null),o=S(t,r);return s.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),p.jsx(A.div,{...e,ref:o})});Ct.displayName=Et;function bt(e,t=globalThis?.document){const n=j(e),r=s.useRef(!1),o=s.useRef(()=>{});return s.useEffect(()=>{const i=u=>{if(u.target&&!r.current){let c=function(){Ee(wt,n,l,{discrete:!0})};const l={originalEvent:u};u.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Tt(e,t=globalThis?.document){const n=j(e),r=s.useRef(!1);return s.useEffect(()=>{const o=i=>{i.target&&!r.current&&Ee(Pt,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function fe(){const e=new CustomEvent(K);document.dispatchEvent(e)}function Ee(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?yt(o,i):o.dispatchEvent(i)}var N=globalThis?.document?s.useLayoutEffect:()=>{},_t=s.useId||(()=>{}),Ot=0;function At(e){const[t,n]=s.useState(_t());return N(()=>{n(r=>r??String(Ot++))},[e]),t?`radix-${t}`:""}var Rt="Arrow",Ce=s.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...i}=e;return p.jsx(A.svg,{...i,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:p.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ce.displayName=Rt;var Nt=Ce;function St(e){const[t,n]=s.useState(void 0);return N(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let a,u;if("borderBoxSize"in i){const c=i.borderBoxSize,l=Array.isArray(c)?c[0]:c;a=l.inlineSize,u=l.blockSize}else a=e.offsetWidth,u=e.offsetHeight;n({width:a,height:u})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Q="Popper",[be,Te]=ye(Q),[Dt,_e]=be(Q),Oe=e=>{const{__scopePopper:t,children:n}=e,[r,o]=s.useState(null);return p.jsx(Dt,{scope:t,anchor:r,onAnchorChange:o,children:n})};Oe.displayName=Q;var Ae="PopperAnchor",Re=s.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=_e(Ae,n),a=s.useRef(null),u=S(t,a);return s.useEffect(()=>{i.onAnchorChange(r?.current||a.current)}),r?null:p.jsx(A.div,{...o,ref:u})});Re.displayName=Ae;var ee="PopperContent",[Lt,It]=be(ee),Ne=s.forwardRef((e,t)=>{const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:a=0,arrowPadding:u=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:v=!1,updatePositionStrategy:h="optimized",onPlaced:m,...y}=e,x=_e(ee,n),[P,w]=s.useState(null),C=S(t,M=>w(M)),[E,b]=s.useState(null),O=St(E),g=O?.width??0,R=O?.height??0,$=r+(i!=="center"?"-"+i:""),k=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},oe=Array.isArray(l)?l:[l],Ye=oe.length>0,H={padding:k,boundary:oe.filter(kt),altBoundary:Ye},{refs:Xe,floatingStyles:se,placement:Ke,isPositioned:W,middlewareData:D}=T.useFloating({strategy:"fixed",placement:$,whileElementsMounted:(...M)=>T.autoUpdate(...M,{animationFrame:h==="always"}),elements:{reference:x.anchor},middleware:[T.offset({mainAxis:o+R,alignmentAxis:a}),c&&T.shift({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?T.limitShift():void 0,...H}),c&&T.flip({...H}),T.size({...H,apply:({elements:M,rects:ce,availableWidth:rt,availableHeight:ot})=>{const{width:st,height:it}=ce.reference,B=M.floating.style;B.setProperty("--radix-popper-available-width",`${rt}px`),B.setProperty("--radix-popper-available-height",`${ot}px`),B.setProperty("--radix-popper-anchor-width",`${st}px`),B.setProperty("--radix-popper-anchor-height",`${it}px`)}}),E&&T.arrow({element:E,padding:u}),Mt({arrowWidth:g,arrowHeight:R}),v&&T.hide({strategy:"referenceHidden",...H})]}),[ie,Ze]=Le(Ke),ae=j(m);N(()=>{W&&ae?.()},[W,ae]);const Je=D.arrow?.x,Qe=D.arrow?.y,et=D.arrow?.centerOffset!==0,[tt,nt]=s.useState();return N(()=>{P&&nt(window.getComputedStyle(P).zIndex)},[P]),p.jsx("div",{ref:Xe.setFloating,"data-radix-popper-content-wrapper":"",style:{...se,transform:W?se.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:tt,"--radix-popper-transform-origin":[D.transformOrigin?.x,D.transformOrigin?.y].join(" "),...D.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:p.jsx(Lt,{scope:n,placedSide:ie,onArrowChange:b,arrowX:Je,arrowY:Qe,shouldHideArrow:et,children:p.jsx(A.div,{"data-side":ie,"data-align":Ze,...y,ref:C,style:{...y.style,animation:W?void 0:"none"}})})})});Ne.displayName=ee;var Se="PopperArrow",jt={top:"bottom",right:"left",bottom:"top",left:"right"},De=s.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=It(Se,r),a=jt[i.placedSide];return p.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:p.jsx(Nt,{...o,ref:n,style:{...o.style,display:"block"}})})});De.displayName=Se;function kt(e){return e!==null}var Mt=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:o}=t,a=o.arrow?.centerOffset!==0,u=a?0:e.arrowWidth,c=a?0:e.arrowHeight,[l,d]=Le(n),f={start:"0%",center:"50%",end:"100%"}[d],v=(o.arrow?.x??0)+u/2,h=(o.arrow?.y??0)+c/2;let m="",y="";return l==="bottom"?(m=a?f:`${v}px`,y=`${-c}px`):l==="top"?(m=a?f:`${v}px`,y=`${r.floating.height+c}px`):l==="right"?(m=`${-c}px`,y=a?f:`${h}px`):l==="left"&&(m=`${r.floating.width+c}px`,y=a?f:`${h}px`),{data:{x:m,y}}}});function Le(e){const[t,n="center"]=e.split("-");return[t,n]}var Ft=Oe,$t=Re,Ht=Ne,Wt=De,Bt="Portal",Ie=s.forwardRef((e,t)=>{const{container:n,...r}=e,[o,i]=s.useState(!1);N(()=>i(!0),[]);const a=n||o&&globalThis?.document?.body;return a?he.createPortal(p.jsx(A.div,{...r,ref:t}),a):null});Ie.displayName=Bt;function Ut(e,t){return s.useReducer((n,r)=>t[n][r]??n,e)}var te=e=>{const{present:t,children:n}=e,r=zt(t),o=typeof n=="function"?n({present:r.isPresent}):s.Children.only(n),i=S(r.ref,qt(o));return typeof n=="function"||r.isPresent?s.cloneElement(o,{ref:i}):null};te.displayName="Presence";function zt(e){const[t,n]=s.useState(),r=s.useRef({}),o=s.useRef(e),i=s.useRef("none"),a=e?"mounted":"unmounted",[u,c]=Ut(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return s.useEffect(()=>{const l=U(r.current);i.current=u==="mounted"?l:"none"},[u]),N(()=>{const l=r.current,d=o.current;if(d!==e){const v=i.current,h=U(l);e?c("MOUNT"):h==="none"||l?.display==="none"?c("UNMOUNT"):c(d&&v!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),N(()=>{if(t){let l;const d=t.ownerDocument.defaultView??window,f=h=>{const y=U(r.current).includes(h.animationName);if(h.target===t&&y&&(c("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",l=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},v=h=>{h.target===t&&(i.current=U(r.current))};return t.addEventListener("animationstart",v),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(l),t.removeEventListener("animationstart",v),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:s.useCallback(l=>{l&&(r.current=getComputedStyle(l)),n(l)},[])}}function U(e){return e?.animationName||"none"}function qt(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Vt({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=Gt({defaultProp:t,onChange:n}),i=e!==void 0,a=i?e:r,u=j(n),c=s.useCallback(l=>{if(i){const f=typeof l=="function"?l(e):l;f!==e&&u(f)}else o(l)},[i,e,o,u]);return[a,c]}function Gt({defaultProp:e,onChange:t}){const n=s.useState(e),[r]=n,o=s.useRef(r),i=j(t);return s.useEffect(()=>{o.current!==r&&(i(r),o.current=r)},[r,o,i]),n}var Yt="VisuallyHidden",je=s.forwardRef((e,t)=>p.jsx(A.span,{...e,ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));je.displayName=Yt;var Xt=je,[z]=ye("Tooltip",[Te]),q=Te(),ke="TooltipProvider",Kt=700,Z="tooltip.open",[Zt,ne]=z(ke),Me=e=>{const{__scopeTooltip:t,delayDuration:n=Kt,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:i}=e,[a,u]=s.useState(!0),c=s.useRef(!1),l=s.useRef(0);return s.useEffect(()=>{const d=l.current;return()=>window.clearTimeout(d)},[]),p.jsx(Zt,{scope:t,isOpenDelayed:a,delayDuration:n,onOpen:s.useCallback(()=>{window.clearTimeout(l.current),u(!1)},[]),onClose:s.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>u(!0),r)},[r]),isPointerInTransitRef:c,onPointerInTransitChange:s.useCallback(d=>{c.current=d},[]),disableHoverableContent:o,children:i})};Me.displayName=ke;var V="Tooltip",[Jt,F]=z(V),Fe=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o=!1,onOpenChange:i,disableHoverableContent:a,delayDuration:u}=e,c=ne(V,e.__scopeTooltip),l=q(t),[d,f]=s.useState(null),v=At(),h=s.useRef(0),m=a??c.disableHoverableContent,y=u??c.delayDuration,x=s.useRef(!1),[P=!1,w]=Vt({prop:r,defaultProp:o,onChange:g=>{g?(c.onOpen(),document.dispatchEvent(new CustomEvent(Z))):c.onClose(),i?.(g)}}),C=s.useMemo(()=>P?x.current?"delayed-open":"instant-open":"closed",[P]),E=s.useCallback(()=>{window.clearTimeout(h.current),h.current=0,x.current=!1,w(!0)},[w]),b=s.useCallback(()=>{window.clearTimeout(h.current),h.current=0,w(!1)},[w]),O=s.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{x.current=!0,w(!0),h.current=0},y)},[y,w]);return s.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),p.jsx(Ft,{...l,children:p.jsx(Jt,{scope:t,contentId:v,open:P,stateAttribute:C,trigger:d,onTriggerChange:f,onTriggerEnter:s.useCallback(()=>{c.isOpenDelayed?O():E()},[c.isOpenDelayed,O,E]),onTriggerLeave:s.useCallback(()=>{m?b():(window.clearTimeout(h.current),h.current=0)},[b,m]),onOpen:E,onClose:b,disableHoverableContent:m,children:n})})};Fe.displayName=V;var J="TooltipTrigger",$e=s.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=F(J,n),i=ne(J,n),a=q(n),u=s.useRef(null),c=S(t,u,o.onTriggerChange),l=s.useRef(!1),d=s.useRef(!1),f=s.useCallback(()=>l.current=!1,[]);return s.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),p.jsx($t,{asChild:!0,...a,children:p.jsx(A.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:_(e.onPointerMove,v=>{v.pointerType!=="touch"&&!d.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:_(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:_(e.onPointerDown,()=>{l.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:_(e.onFocus,()=>{l.current||o.onOpen()}),onBlur:_(e.onBlur,o.onClose),onClick:_(e.onClick,o.onClose)})})});$e.displayName=J;var re="TooltipPortal",[Qt,en]=z(re,{forceMount:void 0}),He=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,i=F(re,t);return p.jsx(Qt,{scope:t,forceMount:n,children:p.jsx(te,{present:n||i.open,children:p.jsx(Ie,{asChild:!0,container:o,children:r})})})};He.displayName=re;var I="TooltipContent",We=s.forwardRef((e,t)=>{const n=en(I,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,a=F(I,e.__scopeTooltip);return p.jsx(te,{present:r||a.open,children:a.disableHoverableContent?p.jsx(Be,{side:o,...i,ref:t}):p.jsx(tn,{side:o,...i,ref:t})})}),tn=s.forwardRef((e,t)=>{const n=F(I,e.__scopeTooltip),r=ne(I,e.__scopeTooltip),o=s.useRef(null),i=S(t,o),[a,u]=s.useState(null),{trigger:c,onClose:l}=n,d=o.current,{onPointerInTransitChange:f}=r,v=s.useCallback(()=>{u(null),f(!1)},[f]),h=s.useCallback((m,y)=>{const x=m.currentTarget,P={x:m.clientX,y:m.clientY},w=on(P,x.getBoundingClientRect()),C=sn(P,w),E=an(y.getBoundingClientRect()),b=ln([...C,...E]);u(b),f(!0)},[f]);return s.useEffect(()=>()=>v(),[v]),s.useEffect(()=>{if(c&&d){const m=x=>h(x,d),y=x=>h(x,c);return c.addEventListener("pointerleave",m),d.addEventListener("pointerleave",y),()=>{c.removeEventListener("pointerleave",m),d.removeEventListener("pointerleave",y)}}},[c,d,h,v]),s.useEffect(()=>{if(a){const m=y=>{const x=y.target,P={x:y.clientX,y:y.clientY},w=c?.contains(x)||d?.contains(x),C=!cn(P,a);w?v():C&&(v(),l())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[c,d,a,l,v]),p.jsx(Be,{...e,ref:i})}),[nn,rn]=z(V,{isInside:!1}),Be=s.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:a,...u}=e,c=F(I,n),l=q(n),{onClose:d}=c;return s.useEffect(()=>(document.addEventListener(Z,d),()=>document.removeEventListener(Z,d)),[d]),s.useEffect(()=>{if(c.trigger){const f=v=>{v.target?.contains(c.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,d]),p.jsx(Pe,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:p.jsxs(Ht,{"data-state":c.stateAttribute,...l,...u,ref:t,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[p.jsx(xe,{children:r}),p.jsx(nn,{scope:n,isInside:!0,children:p.jsx(Xt,{id:c.contentId,role:"tooltip",children:o||r})})]})})});We.displayName=I;var Ue="TooltipArrow",ze=s.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=q(n);return rn(Ue,n).isInside?null:p.jsx(Wt,{...o,...r,ref:t})});ze.displayName=Ue;function on(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function sn(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function an(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function cn(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const u=t[i].x,c=t[i].y,l=t[a].x,d=t[a].y;c>r!=d>r&&n<(l-u)*(r-c)/(d-c)+u&&(o=!o)}return o}function ln(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),un(t)}function un(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const i=n[n.length-1],a=n[n.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var dn=Me,pn=Fe,fn=$e,hn=He,vn=We,mn=ze;const yn="_slideDownAndFade_fkagk_1",gn="_slideLeftAndFade_fkagk_1",xn="_slideUpAndFade_fkagk_1",wn="_slideRightAndFade_fkagk_1",Pn={"purpur-tooltip":"_purpur-tooltip_fkagk_1","purpur-tooltip__content":"_purpur-tooltip__content_fkagk_4","purpur-tooltip__content--primary":"_purpur-tooltip__content--primary_fkagk_14","purpur-tooltip__content--primary-negative":"_purpur-tooltip__content--primary-negative_fkagk_17",slideDownAndFade:yn,slideLeftAndFade:gn,slideUpAndFade:xn,slideRightAndFade:wn,"purpur-tooltip__arrow--primary":"_purpur-tooltip__arrow--primary_fkagk_32","purpur-tooltip__arrow--primary-negative":"_purpur-tooltip__arrow--primary-negative_fkagk_35"},G=ut.c.bind(Pn),qe={TOP:"top",BOTTOM:"bottom",LEFT:"left",RIGHT:"right"},Ve={START:"start",CENTER:"center",END:"end"},L="purpur-tooltip",Ge=Y.forwardRef(({["data-testid"]:e,buttonSize:t="md",children:n,className:r,container:o,contentClassName:i,negative:a=!1,position:u=qe.TOP,align:c=Ve.CENTER,triggerAriaLabel:l,triggerElement:d,...f},v)=>{const[h,m]=Y.useState(!1),y=lt.useThemePortalContainer(),x=o===void 0?y:o??void 0,P=G(r,L,`${L}--primary${a?"-negative":""}`),w=p.jsx(le.Button,{ref:v,"aria-label":l??"","aria-expanded":h,variant:le.BUTTON_VARIANT.TERTIARY_PURPLE,negative:a,iconOnly:!0,"data-testid":`${e}-trigger-button`,size:t,children:p.jsx(at.r,{size:"md"})});return p.jsx("div",{"data-testid":e,className:P,children:p.jsx(dn,{delayDuration:parseInt(ct.purpurMotionDuration400),children:p.jsxs(pn,{open:h,onOpenChange:m,...f,children:[p.jsx(fn,{asChild:!0,onClick:C=>{C.preventDefault(),m(!0)},children:d??w}),p.jsx(hn,{container:x,children:p.jsxs(vn,{side:u,align:c,className:G(i,`${L}__content`,`${L}__content--primary${a?"-negative":""}`),sideOffset:-5,"data-testid":`${e}-content`,children:[typeof n=="string"?p.jsx(ue.Paragraph,{variant:ue.ParagraphVariant.PARAGRAPH100,negative:!a,"data-testid":`${e}-paragraph`,children:n}):n,p.jsx(mn,{className:G(`${L}__arrow`,`${L}__arrow--primary${a?"-negative":""}`)})]})})]})})})});Ge.displayName="Tooltip";exports.TOOLTIP_ALIGN=Ve;exports.TOOLTIP_POSITION=qe;exports.Tooltip=Ge;
2
- //# sourceMappingURL=tooltip-CDnJKoIA.js.map
1
+ "use strict";const p=require("react/jsx-runtime"),Y=require("react"),le=require("./button-DmybVApa.js"),at=require("./info.es-Br84jly5.js"),ue=require("./paragraph-B8HFdNne.js"),ct=require("./variables-BSBunpiY.js");require("./ThemeProvider-BJGm3zai.js");const lt=require("./useThemePortalContainer-CUcqV327.js"),he=require("react-dom"),T=require("./floating-ui.react-dom-Cc_YSprQ.js"),ut=require("./bind-DeUYJ6m9.js");function ve(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const s=ve(Y),dt=ve(he);function _(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o.defaultPrevented)return t?.(o)}}function de(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function me(...e){return t=>{let n=!1;const r=e.map(o=>{const i=de(o,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<r.length;o++){const i=r[o];typeof i=="function"?i():de(e[o],null)}}}}function S(...e){return s.useCallback(me(...e),e)}function ye(e,t=[]){let n=[];function r(i,a){const u=s.createContext(a),c=n.length;n=[...n,a];const l=f=>{const{scope:v,children:h,...m}=f,y=v?.[e]?.[c]||u,x=s.useMemo(()=>m,Object.values(m));return p.jsx(y.Provider,{value:x,children:h})};l.displayName=i+"Provider";function d(f,v){const h=v?.[e]?.[c]||u,m=s.useContext(h);if(m)return m;if(a!==void 0)return a;throw new Error(`\`${f}\` must be used within \`${i}\``)}return[l,d]}const o=()=>{const i=n.map(a=>s.createContext(a));return function(u){const c=u?.[e]||i;return s.useMemo(()=>({[`__scope${e}`]:{...u,[e]:c}}),[u,c])}};return o.scopeName=e,[r,pt(o,...t)]}function pt(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const a=r.reduce((u,{useScope:c,scopeName:l})=>{const f=c(i)[`__scope${l}`];return{...u,...f}},{});return s.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}var ge=s.forwardRef((e,t)=>{const{children:n,...r}=e,o=s.Children.toArray(n),i=o.find(ft);if(i){const a=i.props.children,u=o.map(c=>c===i?s.Children.count(a)>1?s.Children.only(null):s.isValidElement(a)?a.props.children:null:c);return p.jsx(X,{...r,ref:t,children:s.isValidElement(a)?s.cloneElement(a,void 0,u):null})}return p.jsx(X,{...r,ref:t,children:n})});ge.displayName="Slot";var X=s.forwardRef((e,t)=>{const{children:n,...r}=e;if(s.isValidElement(n)){const o=vt(n),i=ht(r,n.props);return n.type!==s.Fragment&&(i.ref=t?me(t,o):o),s.cloneElement(n,i)}return s.Children.count(n)>1?s.Children.only(null):null});X.displayName="SlotClone";var xe=({children:e})=>p.jsx(p.Fragment,{children:e});function ft(e){return s.isValidElement(e)&&e.type===xe}function ht(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...u)=>{i(...u),o(...u)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function vt(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var mt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],A=mt.reduce((e,t)=>{const n=s.forwardRef((r,o)=>{const{asChild:i,...a}=r,u=i?ge:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),p.jsx(u,{...a,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function yt(e,t){e&&dt.flushSync(()=>e.dispatchEvent(t))}function j(e){const t=s.useRef(e);return s.useEffect(()=>{t.current=e}),s.useMemo(()=>(...n)=>t.current?.(...n),[])}function gt(e,t=globalThis?.document){const n=j(e);s.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var xt="DismissableLayer",K="dismissableLayer.update",wt="dismissableLayer.pointerDownOutside",Pt="dismissableLayer.focusOutside",pe,we=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Pe=s.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:a,onDismiss:u,...c}=e,l=s.useContext(we),[d,f]=s.useState(null),v=d?.ownerDocument??globalThis?.document,[,h]=s.useState({}),m=S(t,g=>f(g)),y=Array.from(l.layers),[x]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),P=y.indexOf(x),w=d?y.indexOf(d):-1,C=l.layersWithOutsidePointerEventsDisabled.size>0,E=w>=P,b=bt(g=>{const R=g.target,$=[...l.branches].some(k=>k.contains(R));!E||$||(o?.(g),a?.(g),g.defaultPrevented||u?.())},v),O=Tt(g=>{const R=g.target;[...l.branches].some(k=>k.contains(R))||(i?.(g),a?.(g),g.defaultPrevented||u?.())},v);return gt(g=>{w===l.layers.size-1&&(r?.(g),!g.defaultPrevented&&u&&(g.preventDefault(),u()))},v),s.useEffect(()=>{if(d)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(pe=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(d)),l.layers.add(d),fe(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(v.body.style.pointerEvents=pe)}},[d,v,n,l]),s.useEffect(()=>()=>{d&&(l.layers.delete(d),l.layersWithOutsidePointerEventsDisabled.delete(d),fe())},[d,l]),s.useEffect(()=>{const g=()=>h({});return document.addEventListener(K,g),()=>document.removeEventListener(K,g)},[]),p.jsx(A.div,{...c,ref:m,style:{pointerEvents:C?E?"auto":"none":void 0,...e.style},onFocusCapture:_(e.onFocusCapture,O.onFocusCapture),onBlurCapture:_(e.onBlurCapture,O.onBlurCapture),onPointerDownCapture:_(e.onPointerDownCapture,b.onPointerDownCapture)})});Pe.displayName=xt;var Et="DismissableLayerBranch",Ct=s.forwardRef((e,t)=>{const n=s.useContext(we),r=s.useRef(null),o=S(t,r);return s.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),p.jsx(A.div,{...e,ref:o})});Ct.displayName=Et;function bt(e,t=globalThis?.document){const n=j(e),r=s.useRef(!1),o=s.useRef(()=>{});return s.useEffect(()=>{const i=u=>{if(u.target&&!r.current){let c=function(){Ee(wt,n,l,{discrete:!0})};const l={originalEvent:u};u.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Tt(e,t=globalThis?.document){const n=j(e),r=s.useRef(!1);return s.useEffect(()=>{const o=i=>{i.target&&!r.current&&Ee(Pt,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function fe(){const e=new CustomEvent(K);document.dispatchEvent(e)}function Ee(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?yt(o,i):o.dispatchEvent(i)}var N=globalThis?.document?s.useLayoutEffect:()=>{},_t=s.useId||(()=>{}),Ot=0;function At(e){const[t,n]=s.useState(_t());return N(()=>{n(r=>r??String(Ot++))},[e]),t?`radix-${t}`:""}var Rt="Arrow",Ce=s.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...i}=e;return p.jsx(A.svg,{...i,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:p.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ce.displayName=Rt;var Nt=Ce;function St(e){const[t,n]=s.useState(void 0);return N(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let a,u;if("borderBoxSize"in i){const c=i.borderBoxSize,l=Array.isArray(c)?c[0]:c;a=l.inlineSize,u=l.blockSize}else a=e.offsetWidth,u=e.offsetHeight;n({width:a,height:u})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Q="Popper",[be,Te]=ye(Q),[Dt,_e]=be(Q),Oe=e=>{const{__scopePopper:t,children:n}=e,[r,o]=s.useState(null);return p.jsx(Dt,{scope:t,anchor:r,onAnchorChange:o,children:n})};Oe.displayName=Q;var Ae="PopperAnchor",Re=s.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=_e(Ae,n),a=s.useRef(null),u=S(t,a);return s.useEffect(()=>{i.onAnchorChange(r?.current||a.current)}),r?null:p.jsx(A.div,{...o,ref:u})});Re.displayName=Ae;var ee="PopperContent",[Lt,It]=be(ee),Ne=s.forwardRef((e,t)=>{const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:a=0,arrowPadding:u=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:v=!1,updatePositionStrategy:h="optimized",onPlaced:m,...y}=e,x=_e(ee,n),[P,w]=s.useState(null),C=S(t,M=>w(M)),[E,b]=s.useState(null),O=St(E),g=O?.width??0,R=O?.height??0,$=r+(i!=="center"?"-"+i:""),k=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},oe=Array.isArray(l)?l:[l],Ye=oe.length>0,H={padding:k,boundary:oe.filter(kt),altBoundary:Ye},{refs:Xe,floatingStyles:se,placement:Ke,isPositioned:W,middlewareData:D}=T.useFloating({strategy:"fixed",placement:$,whileElementsMounted:(...M)=>T.autoUpdate(...M,{animationFrame:h==="always"}),elements:{reference:x.anchor},middleware:[T.offset({mainAxis:o+R,alignmentAxis:a}),c&&T.shift({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?T.limitShift():void 0,...H}),c&&T.flip({...H}),T.size({...H,apply:({elements:M,rects:ce,availableWidth:rt,availableHeight:ot})=>{const{width:st,height:it}=ce.reference,B=M.floating.style;B.setProperty("--radix-popper-available-width",`${rt}px`),B.setProperty("--radix-popper-available-height",`${ot}px`),B.setProperty("--radix-popper-anchor-width",`${st}px`),B.setProperty("--radix-popper-anchor-height",`${it}px`)}}),E&&T.arrow({element:E,padding:u}),Mt({arrowWidth:g,arrowHeight:R}),v&&T.hide({strategy:"referenceHidden",...H})]}),[ie,Ze]=Le(Ke),ae=j(m);N(()=>{W&&ae?.()},[W,ae]);const Je=D.arrow?.x,Qe=D.arrow?.y,et=D.arrow?.centerOffset!==0,[tt,nt]=s.useState();return N(()=>{P&&nt(window.getComputedStyle(P).zIndex)},[P]),p.jsx("div",{ref:Xe.setFloating,"data-radix-popper-content-wrapper":"",style:{...se,transform:W?se.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:tt,"--radix-popper-transform-origin":[D.transformOrigin?.x,D.transformOrigin?.y].join(" "),...D.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:p.jsx(Lt,{scope:n,placedSide:ie,onArrowChange:b,arrowX:Je,arrowY:Qe,shouldHideArrow:et,children:p.jsx(A.div,{"data-side":ie,"data-align":Ze,...y,ref:C,style:{...y.style,animation:W?void 0:"none"}})})})});Ne.displayName=ee;var Se="PopperArrow",jt={top:"bottom",right:"left",bottom:"top",left:"right"},De=s.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=It(Se,r),a=jt[i.placedSide];return p.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:p.jsx(Nt,{...o,ref:n,style:{...o.style,display:"block"}})})});De.displayName=Se;function kt(e){return e!==null}var Mt=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:o}=t,a=o.arrow?.centerOffset!==0,u=a?0:e.arrowWidth,c=a?0:e.arrowHeight,[l,d]=Le(n),f={start:"0%",center:"50%",end:"100%"}[d],v=(o.arrow?.x??0)+u/2,h=(o.arrow?.y??0)+c/2;let m="",y="";return l==="bottom"?(m=a?f:`${v}px`,y=`${-c}px`):l==="top"?(m=a?f:`${v}px`,y=`${r.floating.height+c}px`):l==="right"?(m=`${-c}px`,y=a?f:`${h}px`):l==="left"&&(m=`${r.floating.width+c}px`,y=a?f:`${h}px`),{data:{x:m,y}}}});function Le(e){const[t,n="center"]=e.split("-");return[t,n]}var Ft=Oe,$t=Re,Ht=Ne,Wt=De,Bt="Portal",Ie=s.forwardRef((e,t)=>{const{container:n,...r}=e,[o,i]=s.useState(!1);N(()=>i(!0),[]);const a=n||o&&globalThis?.document?.body;return a?he.createPortal(p.jsx(A.div,{...r,ref:t}),a):null});Ie.displayName=Bt;function Ut(e,t){return s.useReducer((n,r)=>t[n][r]??n,e)}var te=e=>{const{present:t,children:n}=e,r=zt(t),o=typeof n=="function"?n({present:r.isPresent}):s.Children.only(n),i=S(r.ref,qt(o));return typeof n=="function"||r.isPresent?s.cloneElement(o,{ref:i}):null};te.displayName="Presence";function zt(e){const[t,n]=s.useState(),r=s.useRef({}),o=s.useRef(e),i=s.useRef("none"),a=e?"mounted":"unmounted",[u,c]=Ut(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return s.useEffect(()=>{const l=U(r.current);i.current=u==="mounted"?l:"none"},[u]),N(()=>{const l=r.current,d=o.current;if(d!==e){const v=i.current,h=U(l);e?c("MOUNT"):h==="none"||l?.display==="none"?c("UNMOUNT"):c(d&&v!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),N(()=>{if(t){let l;const d=t.ownerDocument.defaultView??window,f=h=>{const y=U(r.current).includes(h.animationName);if(h.target===t&&y&&(c("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",l=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},v=h=>{h.target===t&&(i.current=U(r.current))};return t.addEventListener("animationstart",v),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(l),t.removeEventListener("animationstart",v),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:s.useCallback(l=>{l&&(r.current=getComputedStyle(l)),n(l)},[])}}function U(e){return e?.animationName||"none"}function qt(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Vt({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=Gt({defaultProp:t,onChange:n}),i=e!==void 0,a=i?e:r,u=j(n),c=s.useCallback(l=>{if(i){const f=typeof l=="function"?l(e):l;f!==e&&u(f)}else o(l)},[i,e,o,u]);return[a,c]}function Gt({defaultProp:e,onChange:t}){const n=s.useState(e),[r]=n,o=s.useRef(r),i=j(t);return s.useEffect(()=>{o.current!==r&&(i(r),o.current=r)},[r,o,i]),n}var Yt="VisuallyHidden",je=s.forwardRef((e,t)=>p.jsx(A.span,{...e,ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));je.displayName=Yt;var Xt=je,[z]=ye("Tooltip",[Te]),q=Te(),ke="TooltipProvider",Kt=700,Z="tooltip.open",[Zt,ne]=z(ke),Me=e=>{const{__scopeTooltip:t,delayDuration:n=Kt,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:i}=e,[a,u]=s.useState(!0),c=s.useRef(!1),l=s.useRef(0);return s.useEffect(()=>{const d=l.current;return()=>window.clearTimeout(d)},[]),p.jsx(Zt,{scope:t,isOpenDelayed:a,delayDuration:n,onOpen:s.useCallback(()=>{window.clearTimeout(l.current),u(!1)},[]),onClose:s.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>u(!0),r)},[r]),isPointerInTransitRef:c,onPointerInTransitChange:s.useCallback(d=>{c.current=d},[]),disableHoverableContent:o,children:i})};Me.displayName=ke;var V="Tooltip",[Jt,F]=z(V),Fe=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o=!1,onOpenChange:i,disableHoverableContent:a,delayDuration:u}=e,c=ne(V,e.__scopeTooltip),l=q(t),[d,f]=s.useState(null),v=At(),h=s.useRef(0),m=a??c.disableHoverableContent,y=u??c.delayDuration,x=s.useRef(!1),[P=!1,w]=Vt({prop:r,defaultProp:o,onChange:g=>{g?(c.onOpen(),document.dispatchEvent(new CustomEvent(Z))):c.onClose(),i?.(g)}}),C=s.useMemo(()=>P?x.current?"delayed-open":"instant-open":"closed",[P]),E=s.useCallback(()=>{window.clearTimeout(h.current),h.current=0,x.current=!1,w(!0)},[w]),b=s.useCallback(()=>{window.clearTimeout(h.current),h.current=0,w(!1)},[w]),O=s.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{x.current=!0,w(!0),h.current=0},y)},[y,w]);return s.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),p.jsx(Ft,{...l,children:p.jsx(Jt,{scope:t,contentId:v,open:P,stateAttribute:C,trigger:d,onTriggerChange:f,onTriggerEnter:s.useCallback(()=>{c.isOpenDelayed?O():E()},[c.isOpenDelayed,O,E]),onTriggerLeave:s.useCallback(()=>{m?b():(window.clearTimeout(h.current),h.current=0)},[b,m]),onOpen:E,onClose:b,disableHoverableContent:m,children:n})})};Fe.displayName=V;var J="TooltipTrigger",$e=s.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=F(J,n),i=ne(J,n),a=q(n),u=s.useRef(null),c=S(t,u,o.onTriggerChange),l=s.useRef(!1),d=s.useRef(!1),f=s.useCallback(()=>l.current=!1,[]);return s.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),p.jsx($t,{asChild:!0,...a,children:p.jsx(A.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:_(e.onPointerMove,v=>{v.pointerType!=="touch"&&!d.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:_(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:_(e.onPointerDown,()=>{l.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:_(e.onFocus,()=>{l.current||o.onOpen()}),onBlur:_(e.onBlur,o.onClose),onClick:_(e.onClick,o.onClose)})})});$e.displayName=J;var re="TooltipPortal",[Qt,en]=z(re,{forceMount:void 0}),He=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,i=F(re,t);return p.jsx(Qt,{scope:t,forceMount:n,children:p.jsx(te,{present:n||i.open,children:p.jsx(Ie,{asChild:!0,container:o,children:r})})})};He.displayName=re;var I="TooltipContent",We=s.forwardRef((e,t)=>{const n=en(I,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,a=F(I,e.__scopeTooltip);return p.jsx(te,{present:r||a.open,children:a.disableHoverableContent?p.jsx(Be,{side:o,...i,ref:t}):p.jsx(tn,{side:o,...i,ref:t})})}),tn=s.forwardRef((e,t)=>{const n=F(I,e.__scopeTooltip),r=ne(I,e.__scopeTooltip),o=s.useRef(null),i=S(t,o),[a,u]=s.useState(null),{trigger:c,onClose:l}=n,d=o.current,{onPointerInTransitChange:f}=r,v=s.useCallback(()=>{u(null),f(!1)},[f]),h=s.useCallback((m,y)=>{const x=m.currentTarget,P={x:m.clientX,y:m.clientY},w=on(P,x.getBoundingClientRect()),C=sn(P,w),E=an(y.getBoundingClientRect()),b=ln([...C,...E]);u(b),f(!0)},[f]);return s.useEffect(()=>()=>v(),[v]),s.useEffect(()=>{if(c&&d){const m=x=>h(x,d),y=x=>h(x,c);return c.addEventListener("pointerleave",m),d.addEventListener("pointerleave",y),()=>{c.removeEventListener("pointerleave",m),d.removeEventListener("pointerleave",y)}}},[c,d,h,v]),s.useEffect(()=>{if(a){const m=y=>{const x=y.target,P={x:y.clientX,y:y.clientY},w=c?.contains(x)||d?.contains(x),C=!cn(P,a);w?v():C&&(v(),l())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[c,d,a,l,v]),p.jsx(Be,{...e,ref:i})}),[nn,rn]=z(V,{isInside:!1}),Be=s.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:a,...u}=e,c=F(I,n),l=q(n),{onClose:d}=c;return s.useEffect(()=>(document.addEventListener(Z,d),()=>document.removeEventListener(Z,d)),[d]),s.useEffect(()=>{if(c.trigger){const f=v=>{v.target?.contains(c.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,d]),p.jsx(Pe,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:p.jsxs(Ht,{"data-state":c.stateAttribute,...l,...u,ref:t,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[p.jsx(xe,{children:r}),p.jsx(nn,{scope:n,isInside:!0,children:p.jsx(Xt,{id:c.contentId,role:"tooltip",children:o||r})})]})})});We.displayName=I;var Ue="TooltipArrow",ze=s.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=q(n);return rn(Ue,n).isInside?null:p.jsx(Wt,{...o,...r,ref:t})});ze.displayName=Ue;function on(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function sn(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function an(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function cn(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const u=t[i].x,c=t[i].y,l=t[a].x,d=t[a].y;c>r!=d>r&&n<(l-u)*(r-c)/(d-c)+u&&(o=!o)}return o}function ln(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),un(t)}function un(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const i=n[n.length-1],a=n[n.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var dn=Me,pn=Fe,fn=$e,hn=He,vn=We,mn=ze;const yn="_slideDownAndFade_fkagk_1",gn="_slideLeftAndFade_fkagk_1",xn="_slideUpAndFade_fkagk_1",wn="_slideRightAndFade_fkagk_1",Pn={"purpur-tooltip":"_purpur-tooltip_fkagk_1","purpur-tooltip__content":"_purpur-tooltip__content_fkagk_4","purpur-tooltip__content--primary":"_purpur-tooltip__content--primary_fkagk_14","purpur-tooltip__content--primary-negative":"_purpur-tooltip__content--primary-negative_fkagk_17",slideDownAndFade:yn,slideLeftAndFade:gn,slideUpAndFade:xn,slideRightAndFade:wn,"purpur-tooltip__arrow--primary":"_purpur-tooltip__arrow--primary_fkagk_32","purpur-tooltip__arrow--primary-negative":"_purpur-tooltip__arrow--primary-negative_fkagk_35"},G=ut.c.bind(Pn),qe={TOP:"top",BOTTOM:"bottom",LEFT:"left",RIGHT:"right"},Ve={START:"start",CENTER:"center",END:"end"},L="purpur-tooltip",Ge=Y.forwardRef(({["data-testid"]:e,buttonSize:t="md",children:n,className:r,container:o,contentClassName:i,negative:a=!1,position:u=qe.TOP,align:c=Ve.CENTER,triggerAriaLabel:l,triggerElement:d,...f},v)=>{const[h,m]=Y.useState(!1),y=lt.useThemePortalContainer(),x=o===void 0?y:o??void 0,P=G(r,L,`${L}--primary${a?"-negative":""}`),w=p.jsx(le.Button,{ref:v,"aria-label":l??"","aria-expanded":h,variant:le.BUTTON_VARIANT.TERTIARY_PURPLE,negative:a,iconOnly:!0,"data-testid":`${e}-trigger-button`,size:t,children:p.jsx(at.r,{size:"md"})});return p.jsx("div",{"data-testid":e,className:P,children:p.jsx(dn,{delayDuration:parseInt(ct.purpurMotionDuration400),children:p.jsxs(pn,{open:h,onOpenChange:m,...f,children:[p.jsx(fn,{asChild:!0,onClick:C=>{C.preventDefault(),m(!0)},children:d??w}),p.jsx(hn,{container:x,children:p.jsxs(vn,{side:u,align:c,className:G(i,`${L}__content`,`${L}__content--primary${a?"-negative":""}`),sideOffset:-5,"data-testid":`${e}-content`,children:[typeof n=="string"?p.jsx(ue.Paragraph,{variant:ue.ParagraphVariant.PARAGRAPH100,negative:!a,"data-testid":`${e}-paragraph`,children:n}):n,p.jsx(mn,{className:G(`${L}__arrow`,`${L}__arrow--primary${a?"-negative":""}`)})]})})]})})})});Ge.displayName="Tooltip";exports.TOOLTIP_ALIGN=Ve;exports.TOOLTIP_POSITION=qe;exports.Tooltip=Ge;
2
+ //# sourceMappingURL=tooltip-B-11qk-0.js.map