@popmelt.com/core 0.40.1 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/claude-plugin/.claude-plugin/plugin.json +1 -1
  2. package/codex-plugin/.codex-plugin/plugin.json +1 -1
  3. package/dist/ExploreAttachment-ALV7FL3Y.mjs +1 -0
  4. package/dist/PagePreviewLayer-UPCGG4EV.mjs +1 -0
  5. package/dist/ParticipantRuntime-CBUA7BL5.mjs +1 -0
  6. package/dist/PhoneHostGate-TVNOJYL5.mjs +1 -0
  7. package/dist/PopmeltProvider-5g-1VH5a.d.mts +15 -0
  8. package/dist/PopmeltTasteConnectedPane-PD64Q6LF.mjs +1 -0
  9. package/dist/QueuedReplies-ESF5UL3J.mjs +1 -0
  10. package/dist/SamplePlacementOverlay-V533Y4XN.mjs +1 -0
  11. package/dist/ShareProjectPane-PMODH6QQ.mjs +1 -0
  12. package/dist/SuppliedContext-ADMN2D2I.mjs +1 -0
  13. package/dist/{ThreadErrorCard-SUFOXXLG.mjs → ThreadErrorCard-KS2XWRT3.mjs} +1 -1
  14. package/dist/ThreadPanel-5TDPZBAU.mjs +1 -0
  15. package/dist/adapter-react-three-fiber.d.mts +1 -1
  16. package/dist/adapter-react-three-fiber.mjs +1 -1
  17. package/dist/adapter-three.d.mts +1 -1
  18. package/dist/adapter-three.mjs +1 -1
  19. package/dist/bridge-entry.mjs +1 -1
  20. package/dist/browser-runtime-FUXWVGQ7.mjs +1 -0
  21. package/dist/browser.d.mts +4 -4
  22. package/dist/browser.mjs +1 -1
  23. package/dist/canvas-text.d.mts +1 -1
  24. package/dist/{checkFixture-LBDNT3M5.mjs → checkFixture-42NYMFAK.mjs} +1 -1
  25. package/dist/chunk-2TA7N3CI.mjs +1 -0
  26. package/dist/chunk-32BKJ5JN.mjs +1 -0
  27. package/dist/chunk-3HVPVKWV.mjs +1 -0
  28. package/dist/chunk-4RQ5XD3I.mjs +1 -0
  29. package/dist/chunk-5J4BZL6N.mjs +1 -0
  30. package/dist/chunk-6OPX4CUT.mjs +1 -0
  31. package/dist/{chunk-4MLXPN7W.mjs → chunk-776SEJZO.mjs} +1 -1
  32. package/dist/chunk-7OATJ6BO.mjs +1 -0
  33. package/dist/chunk-7VIC4MGC.mjs +1 -0
  34. package/dist/chunk-AET77LFV.mjs +1 -0
  35. package/dist/chunk-ALWPAFIW.mjs +1 -0
  36. package/dist/chunk-AOFKEBLN.mjs +1 -0
  37. package/dist/{chunk-6EO73WJN.mjs → chunk-BSVZXOOS.mjs} +1 -1
  38. package/dist/chunk-D2ONGS5P.mjs +1 -0
  39. package/dist/chunk-DDUXU6LA.mjs +1 -0
  40. package/dist/chunk-DMKBAI2Z.mjs +1 -0
  41. package/dist/chunk-DUWONLQE.mjs +1 -0
  42. package/dist/chunk-EG6UHPJV.mjs +1 -0
  43. package/dist/{chunk-XVQAHYF2.mjs → chunk-FZUHHJWW.mjs} +1 -1
  44. package/dist/{chunk-L3QE62SE.mjs → chunk-GE5BE6PI.mjs} +1 -1
  45. package/dist/{chunk-K22VZV3V.mjs → chunk-GLF7Z5IR.mjs} +1 -1
  46. package/dist/chunk-GLIGPLM4.mjs +1 -0
  47. package/dist/chunk-H3T2O3HA.mjs +1 -0
  48. package/dist/chunk-HFKGW34E.mjs +1 -0
  49. package/dist/{chunk-Q5MIJ5F2.mjs → chunk-HFWGYXPG.mjs} +1 -1
  50. package/dist/{chunk-53QOGFAT.mjs → chunk-ITLRSHNZ.mjs} +1 -1
  51. package/dist/chunk-JWWWU4GY.mjs +1 -0
  52. package/dist/chunk-KD2AOPYP.mjs +1 -0
  53. package/dist/chunk-KE4MQBRY.mjs +1 -0
  54. package/dist/chunk-KF73S7MG.mjs +1 -0
  55. package/dist/{chunk-ZQMKLODZ.mjs → chunk-LDDDSIAQ.mjs} +1 -1
  56. package/dist/chunk-LWPNOBGS.mjs +1 -0
  57. package/dist/{chunk-MPEVFQ43.mjs → chunk-PCUUOIFD.mjs} +1 -1
  58. package/dist/chunk-PRZ6C5X3.mjs +1 -0
  59. package/dist/chunk-PTMHSMZH.mjs +1 -0
  60. package/dist/chunk-RFTQCRGC.mjs +1 -0
  61. package/dist/{chunk-DBCCE7BA.mjs → chunk-S2U2IGUO.mjs} +1 -1
  62. package/dist/{chunk-EUFK7B6S.mjs → chunk-S7IWZSWH.mjs} +1 -1
  63. package/dist/chunk-SOFNYBJD.mjs +1 -0
  64. package/dist/chunk-SZQTGYPS.mjs +1 -0
  65. package/dist/chunk-TA2BMDSC.mjs +30 -0
  66. package/dist/{chunk-ECWY6Z6K.mjs → chunk-ULR4IDEX.mjs} +1 -1
  67. package/dist/{chunk-OECEYJNK.mjs → chunk-VJKC2RJB.mjs} +1 -1
  68. package/dist/chunk-VOL4KS67.mjs +1 -0
  69. package/dist/chunk-VSWRWS2H.mjs +1 -0
  70. package/dist/chunk-W5TNOJOR.mjs +1 -0
  71. package/dist/{chunk-LUTP7QBD.mjs → chunk-WSI2SQWU.mjs} +1 -1
  72. package/dist/chunk-WWNI7JCA.mjs +1 -0
  73. package/dist/chunk-XDZUDDYB.mjs +1 -0
  74. package/dist/chunk-XGSOAF5E.mjs +1 -0
  75. package/dist/chunk-XHTSKQMB.mjs +1 -0
  76. package/dist/chunk-YG3RSK5J.mjs +1 -0
  77. package/dist/chunk-YHCZYT4T.mjs +1 -0
  78. package/dist/chunk-Z4NMA34Y.mjs +1 -0
  79. package/dist/chunk-ZXCAONMC.mjs +1 -0
  80. package/dist/cli.mjs +1 -1
  81. package/dist/codex-note-context-WX33QFE7.mjs +1 -0
  82. package/dist/codex-project-77GHT2I3.mjs +1 -0
  83. package/dist/{codex-session-registry-YNU6LEVH.mjs → codex-session-registry-A3NQRRZ3.mjs} +1 -1
  84. package/dist/codex-store-mount-KFJYT6AS.mjs +1 -0
  85. package/dist/dev-app-port-LHUBCOBE.mjs +1 -0
  86. package/dist/{dev-server-BRrhkH5t.d.mts → dev-server-D8Qxrp1A.d.mts} +2 -1
  87. package/dist/dev-server-FZJ6HDKP.mjs +1 -0
  88. package/dist/guest-admission.mjs +1 -1
  89. package/dist/guest-live-canvas.mjs +1 -1
  90. package/dist/index.d.mts +9 -25
  91. package/dist/index.mjs +1 -1
  92. package/dist/media.d.mts +3 -3
  93. package/dist/memory-store.d.mts +7 -2
  94. package/dist/memory.mjs +1 -1
  95. package/dist/orientation-markup.mjs +1 -0
  96. package/dist/outline-trace.mjs +1 -0
  97. package/dist/{page-interaction-YXHXEYOT.mjs → page-interaction-74JGNCZ5.mjs} +1 -1
  98. package/dist/{page-planes-Jz2yR_Wk.d.mts → page-planes-BeFZ3Wso.d.mts} +15 -472
  99. package/dist/{participantBootstrap-DDOxY-Cy.d.mts → participantBootstrap-BcfNTEe9.d.mts} +3 -3
  100. package/dist/peer-client-B2KMU667.mjs +1 -0
  101. package/dist/phone-app-HNBDX7UX.mjs +1 -0
  102. package/dist/plain-html-H35WPIRO.mjs +1 -0
  103. package/dist/plane-history.mjs +1 -0
  104. package/dist/plugin-astro.d.mts +8 -3
  105. package/dist/plugin-astro.mjs +1 -1
  106. package/dist/plugin-nuxt.d.mts +6 -2
  107. package/dist/plugin-nuxt.mjs +1 -1
  108. package/dist/plugin-vite.d.mts +10 -5
  109. package/dist/plugin-vite.mjs +1 -1
  110. package/dist/protocol-BIUE4rB6.d.mts +9 -0
  111. package/dist/server.d.mts +14 -3
  112. package/dist/server.mjs +1 -1
  113. package/dist/shared-page-6AUYAPJ3.mjs +1 -0
  114. package/dist/steerStyles-C4YBV4TZ.mjs +1 -0
  115. package/dist/sticker-colors.mjs +1 -0
  116. package/dist/sticker-mode.mjs +1 -0
  117. package/dist/{subjects-cLtt9-iK.d.mts → subjects-qHIrZrlt.d.mts} +57 -1
  118. package/dist/taste-constraints.mjs +1 -0
  119. package/dist/taste-contract.mjs +1 -0
  120. package/dist/taste-fragment.mjs +1 -0
  121. package/dist/taste-graph-inspection.mjs +1 -0
  122. package/dist/taste-layout.mjs +1 -0
  123. package/dist/taste-page-composition.mjs +1 -0
  124. package/dist/taste-proposal-session-PSI4TX6H.mjs +1 -0
  125. package/dist/taste-proposal.mjs +1 -0
  126. package/dist/taste-token-math.mjs +1 -0
  127. package/dist/thread-request.mjs +1 -0
  128. package/dist/thread-view-client.d.mts +2 -0
  129. package/dist/thread-view-client.mjs +1 -0
  130. package/dist/thread-view.html +136 -0
  131. package/dist/{video-adapter-xL95wukX.d.mts → video-adapter-B5eap10v.d.mts} +1 -1
  132. package/infra/phone-pairing/app-listener.cjs +107 -0
  133. package/infra/phone-pairing/binding.mjs +369 -20
  134. package/infra/phone-pairing/machine-config.mjs +43 -26
  135. package/infra/phone-pairing/machine-service.mjs +94 -6
  136. package/infra/phone-pairing/machine.mjs +5 -1
  137. package/infra/phone-pairing/reservations.mjs +103 -0
  138. package/infra/phone-pairing/writer-lock.mjs +107 -0
  139. package/package.json +30 -35
  140. package/dist/ExploreAttachment-ZPC5AR5V.mjs +0 -1
  141. package/dist/PagePreviewLayer-C7WBS7IX.mjs +0 -1
  142. package/dist/ParticipantRuntime-CWE62D2G.mjs +0 -1
  143. package/dist/PhoneHostGate-NWJXZBBP.mjs +0 -1
  144. package/dist/PopmeltTasteConnectedPane-2BNDKMMB.mjs +0 -1
  145. package/dist/QueuedReplies-5YG2DN3W.mjs +0 -1
  146. package/dist/SamplePlacementOverlay-ULOV22WR.mjs +0 -1
  147. package/dist/ShareProjectPane-KEE7EYMP.mjs +0 -1
  148. package/dist/SuppliedContext-IT25WBGQ.mjs +0 -1
  149. package/dist/ThreadPanel-NNJHQQSD.mjs +0 -1
  150. package/dist/browser-runtime-G6AEOA4X.mjs +0 -1
  151. package/dist/chunk-2FHGLE7G.mjs +0 -1
  152. package/dist/chunk-32TDB3N4.mjs +0 -1
  153. package/dist/chunk-4EDMISUV.mjs +0 -1
  154. package/dist/chunk-5IZHN3A7.mjs +0 -1
  155. package/dist/chunk-6DU4ITXT.mjs +0 -1
  156. package/dist/chunk-6RC7JZ73.mjs +0 -1
  157. package/dist/chunk-A4GARXVQ.mjs +0 -1
  158. package/dist/chunk-AKEVJPGD.mjs +0 -1
  159. package/dist/chunk-AWWUJO3N.mjs +0 -1
  160. package/dist/chunk-BD7DW4UK.mjs +0 -1
  161. package/dist/chunk-CRZEJJI6.mjs +0 -1
  162. package/dist/chunk-CUVWMYUV.mjs +0 -1
  163. package/dist/chunk-DSTHM3V5.mjs +0 -30
  164. package/dist/chunk-EWTZVC7E.mjs +0 -1
  165. package/dist/chunk-FR6VIGJ2.mjs +0 -1
  166. package/dist/chunk-HVDJYNQ6.mjs +0 -1
  167. package/dist/chunk-KN4GC34I.mjs +0 -1
  168. package/dist/chunk-KUILFVXZ.mjs +0 -1
  169. package/dist/chunk-LLVF422C.mjs +0 -1
  170. package/dist/chunk-MHTX52KW.mjs +0 -1
  171. package/dist/chunk-N37INB4D.mjs +0 -1
  172. package/dist/chunk-NFPUOL4J.mjs +0 -1
  173. package/dist/chunk-OA63PYHZ.mjs +0 -1
  174. package/dist/chunk-PQKSXNIZ.mjs +0 -1
  175. package/dist/chunk-PYGRFSUU.mjs +0 -1
  176. package/dist/chunk-QYNW5LE2.mjs +0 -1
  177. package/dist/chunk-RAABZFBD.mjs +0 -1
  178. package/dist/chunk-REPKQAJK.mjs +0 -1
  179. package/dist/chunk-TMSGNHXH.mjs +0 -1
  180. package/dist/chunk-TVS2ZIAW.mjs +0 -1
  181. package/dist/chunk-UIADZXVT.mjs +0 -1
  182. package/dist/chunk-V7AOJQXQ.mjs +0 -1
  183. package/dist/chunk-WKQGWQ3P.mjs +0 -1
  184. package/dist/chunk-WPU4472Z.mjs +0 -1
  185. package/dist/chunk-WYQZ7DAK.mjs +0 -1
  186. package/dist/chunk-X6I6KQDG.mjs +0 -1
  187. package/dist/chunk-YMWXWXPV.mjs +0 -1
  188. package/dist/codex-note-context-GXC2474A.mjs +0 -1
  189. package/dist/codex-project-HVK7FSWQ.mjs +0 -1
  190. package/dist/codex-store-mount-KHTSSESB.mjs +0 -1
  191. package/dist/dev-server-QMA23NJQ.mjs +0 -1
  192. package/dist/participantBootstrap-BuTrTQbo.d.mts +0 -22
  193. package/dist/peer-client-JL754ZR7.mjs +0 -1
  194. package/dist/plain-html-EF7MUNRZ.mjs +0 -1
  195. package/dist/shared-page-QN2XRXUE.mjs +0 -1
  196. package/dist/steerStyles-E76E44PI.mjs +0 -1
  197. package/dist/taste-proposal-session-AAXK4CFL.mjs +0 -1
  198. package/infra/phone-pairing/README.md +0 -25
@@ -0,0 +1 @@
1
+ import{j as e}from"./chunk-7VIC4MGC.mjs";var t=/^@([\w-]+)(?::\s*[+-]?(?:\d+\.?\d*|\.\d+)(?![\w.]))?(?![\w-]|\s*:)/,r=/^(?:px|rem|em|ex|ch|cap|ic|lh|rlh|vw|vh|vi|vb|vmin|vmax|[sld]v[whib]|cm|mm|q|in|pt|pc|%)$/i,n=e=>String(Number(e.toPrecision(12)));function l(l,i){if(l.length>4096||!/^calc\(/i.test(l))return null;let s=5,u=0,c=()=>{throw Error("Invalid calc expression")},a=()=>{for(;/\s/.test(l[s]??"")&&s<l.length;)s++},m=(e,t="")=>!Number.isFinite(e)||t&&!r.test(t)?c():{kind:t?"length":"number",terms:new Map([[t.toLowerCase(),e]])},f=(e,t)=>({...e,terms:new Map([...e.terms].map(([e,r])=>{let n=r*t;return Number.isFinite(n)||c(),[e,n]}))}),o=()=>{a(),++u>32&&c();try{let r=l[s];if("+"===r||"-"===r)return s++,f(o(),"-"===r?-1:1);if("("===l[s]||/^calc\(/i.test(l.slice(s))){s+="("===l[s]?1:5;let e=h();return a(),")"!==l[s++]&&c(),e}let n=l.slice(s).match(t)?.[0];if(n){s+=n.length;let t=e(i,n);if("layout"!==t?.kind)return c();let r=i.find(e=>e.name.toLowerCase()===n.slice(1).split(":")[0].trim().toLowerCase());return m(t.value,t.unit||("increment"===r?.scaleMode?"":"px"))}let u=l.slice(s).match(/^(\d+\.?\d*|\.\d+)(e[+-]?\d+)?([a-z]+|%)?/i);return u?(s+=u[0].length,m(Number(u[1]+(u[2]??"")),u[3])):c()}finally{u--}},d=()=>{let e=o();for(;;){a();let t=l[s];if("*"!==t&&"/"!==t)return e;s++;let r=o();if("/"===t){let t=r.terms.get("");if("number"!==r.kind||!t)return c();e=f(e,1/t)}else if("number"===r.kind)e=f(e,r.terms.get(""));else{if("number"!==e.kind)return c();e=f(r,e.terms.get(""))}}},h=()=>{let e=d();for(;;){a();let t=l[s];if("+"!==t&&"-"!==t)return e;s++;let r=d();if(e.kind!==r.kind)return c();for(let[n,l]of r.terms){let r=(e.terms.get(n)??0)+l*("-"===t?-1:1);Number.isFinite(r)||c(),e.terms.set(n,r)}}};try{let e=h();if(a(),")"!==l[s++]||l.slice(s).trim())return null;let t=[...e.terms].filter(([,e])=>0!==e);t.length||t.push([e.terms.keys().next().value??"",0]);let[r,i]=t[0];return{css:1===t.length?`${n(i)}${r}`:`calc(${t.map(([e,t],r)=>`${r?t<0?" - ":" + ":t<0?"-":""}${n(Math.abs(t))}${e}`).join("")})`,kind:e.kind,...1===t.length?{value:i,unit:r}:{}}}catch{return null}}function i(e){let t=[],r=/url\((?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^)'"])*\)|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\/\*[\s\S]*?\*\/|\bcalc\(/gi;for(let n;n=r.exec(e);){if(!/^calc\(/i.test(n[0]))continue;let l=1,i=r.lastIndex;for(;i<e.length&&l;)"("===e[i]?l++:")"===e[i]&&l--,i++;t.push({start:n.index,end:i,text:e.slice(n.index,i)}),r.lastIndex=i}return t}function s(e,t){let r=e;for(let n of i(e).reverse()){let e=l(n.text,t);if(!e)return null;r=r.slice(0,n.start)+e.css+r.slice(n.end)}return r}export{t as a,l as b,i as c,s as d};
@@ -0,0 +1 @@
1
+ "use client";import{c as i}from"./chunk-CK3CDA3L.mjs";import{a}from"./chunk-7D4BUDKG.mjs";import{a as e}from"./chunk-ADRWR5GI.mjs";import{forwardRef as r}from"react";import{jsx as n,jsxs as t}from"react/jsx-runtime";var o={gap:16,padding:12,radius:20,width:360,viewportGutter:32,identitySize:24},d=`calc(100vw - ${o.viewportGutter}px)`,p={gap:6,padding:"4px 8px",radius:8,iconSize:12},s={gap:3,padding:"2px 6px",radius:8,iconSize:12},c={gap:3,padding:"3px 9px 3px 6px",radius:8,iconSize:10},h=c,l={size:21,padding:3,radius:8,iconSize:15},g={padding:"0 4px",height:18,radius:6},u={fontFamily:e,fontSize:12,fontWeight:500,lineHeight:1.3};function m(i){return{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:s.gap,padding:s.padding,borderRadius:s.radius,border:0,flexShrink:0,background:a[i].control,color:a[i].primary,...u,whiteSpace:"nowrap",cursor:"pointer",transition:"box-shadow 120ms ease"}}var f={compact:{height:24,icon:12},regular:{height:28,icon:14},large:{height:40,icon:16}},b=r(function({theme:a,variant:e="filled",size:r="compact",icon:o,hint:d,above:p,anchorRef:s,hoverDelayMs:c,onReveal:h,style:l,disabled:g,children:u,...b},x){let y,{height:v,icon:z}=f[r],S=o&&null==u;function w(i){return t("button",{type:"button",...b,"aria-describedby":i?[b["aria-describedby"],i].filter(Boolean).join(" "):b["aria-describedby"],ref:x,disabled:g,style:y?{...y,...l}:l,children:[o&&n(o,{size:S?16:z,"aria-hidden":!0}),u]})}return a&&"custom"!==e&&(y={...m(a),minHeight:v,..."compact"!==r&&{padding:"4px 10px",gap:4,fontSize:14},..."ghost"===e&&{background:"transparent"},...S&&{width:v,padding:0},...g&&{opacity:.6,cursor:"default"}}),void 0===d?w():n(i,{hint:!0===d?b["aria-label"]:d,above:p,anchorRef:s,hoverDelayMs:c,onReveal:h,children:w})});export{o as a,d as b,p as c,s as d,c as e,h as f,l as g,g as h,u as i,m as j,b as k};
@@ -1 +1 @@
1
- "use client";import{c as e}from"./chunk-RK6UROPO.mjs";import{o as t,n as o,h as n}from"./chunk-AOTDTBQO.mjs";import{j as i,k as r}from"./chunk-RWZ7SVMO.mjs";import{a}from"./chunk-HAZXZ5TU.mjs";import{h as l,e as s,o as d,X as p,v as c,A as u,b as h}from"./chunk-KF35YUNZ.mjs";import{b as f}from"./chunk-VBH2YQLG.mjs";import{a as m,h as g,d as v,i as b,c as w,m as y,b as x}from"./chunk-LH7HKUCK.mjs";import{K as k}from"./chunk-OA63PYHZ.mjs";import{b as A}from"./chunk-ADRWR5GI.mjs";import{createContext as R,useState as $,useLayoutEffect as L,useContext as j,useId as C,useRef as S}from"react";import{jsxs as D,jsx as O,Fragment as E}from"react/jsx-runtime";var N=R(!0);function P(e,t){let o=e.match(/^oklch\(([^)]+)\)$/i);if(o)return`oklch(${o[1]} / ${t})`;let n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n){return`rgba(${parseInt(n[1],16)}, ${parseInt(n[2],16)}, ${parseInt(n[3],16)}, ${t})`}return`color-mix(in srgb, ${e} ${Math.round(100*t)}%, transparent)`}var z=new WeakMap,F=0,W="popmelt-scroll-anchor",I="popmelt-page-paint",T=`\n[data-popmelt-top-layer-host]::part(${W}) {\n position-anchor: var(--popmelt-anchor) !important;\n}\n[data-popmelt-top-layer-host]::part(${I}) {\n position-anchor: --popmelt-page-origin;\n left: calc(anchor(left, calc(0px - var(--popmelt-painted-x, 0px))) + var(--popmelt-painted-x, 0px));\n top: calc(anchor(top, calc(0px - var(--popmelt-painted-y, 0px))) + var(--popmelt-painted-y, 0px));\n}\n`;function H(e){if(!(e instanceof HTMLElement&&e.getRootNode()===document&&globalThis.CSS?.supports?.("top","anchor(top)")))return;let t=z.get(e);if(!t){let o=getComputedStyle(e).getPropertyValue("anchor-name");if(o&&"none"!==o)return;let n="--popmelt-target-"+ ++F;t={name:n,users:0,previous:e.style.getPropertyValue("anchor-name"),priority:e.style.getPropertyPriority("anchor-name")},z.set(e,t),e.style.setProperty("anchor-name",n)}let o=t;return o.users++,{name:o.name,element:e,release(){--o.users||(z.delete(e),e.style.getPropertyValue("anchor-name")===o.name&&e.style.setProperty("anchor-name",o.previous,o.priority))}}}function M(e){let[t,o]=$();return L(()=>{let t=H(e);return o(t),t?.release},[e]),t&&t.element===e?t.name:void 0}function B(e,t,o,n){return e?{"--popmelt-anchor":e,positionAnchor:e,left:`calc(anchor(left, ${t.left}px) + ${o-t.left}px)`,top:`calc(anchor(top, ${t.top}px) + ${n-t.top}px)`}:{left:o,top:n}}function V(e){let[t,o]=$(null),n=S(null);return L(()=>{if(o(null),!e)return;let t=p(e,"transparent",0,"solid",o);return()=>t?.abort()},[e]),L(()=>{let e=n.current;if(!t||!e)return;let o=()=>{let o=t.matches("path")?[t]:t.querySelectorAll("path"),n=0;for(let t of o){let o=t.getAttribute("d"),i=t.getScreenCTM();if(!o||!i||!t.getClientRects().length)continue;let r=e.children[n++];r||(r=e.ownerDocument.createElementNS("http://www.w3.org/2000/svg","path"),r.setAttribute("vector-effect","non-scaling-stroke"),e.append(r));let a=m(t.ownerDocument)?w({left:0,top:0,width:1,height:1},t.ownerDocument):null,l=a?.width??1,s=a?.height??1,d=`matrix(${i.a*l} ${i.b*s} ${i.c*l} ${i.d*s} ${i.e*l+(a?.x??0)} ${i.f*s+(a?.y??0)})`;r.getAttribute("d")!==o&&r.setAttribute("d",o),r.getAttribute("transform")!==d&&r.setAttribute("transform",d);let p=t.getAttribute("fill-rule")||"nonzero";r.getAttribute("fill-rule")!==p&&r.setAttribute("fill-rule",p)}for(;e.children.length>n;)e.lastElementChild.remove()},i=new MutationObserver(o);i.observe(t,{subtree:!0,attributes:!0,childList:!0});let r,a=()=>{o(),r=requestAnimationFrame(a)};return a(),()=>{i.disconnect(),cancelAnimationFrame(r),e.replaceChildren()}},[t]),{active:!!t,group:n}}function q({painterTarget:e,path:t,polygon:o,bounds:n,clip:i,color:r,selected:a,zIndex:l}){let s=C(),d=s+"-contour",p=V(e),{left:c,top:u,width:f,height:m}=n;return D("svg",{"data-devtools":"sample-spotlight","aria-hidden":"true",width:"100%",height:"100%",style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:l},children:[D("defs",{children:[i&&O("clipPath",{id:s+"-clip",children:O("rect",{x:i.left,y:i.top,width:i.width,height:i.height})}),O("g",{id:d,clipPath:i?`url(#${s}-clip)`:void 0,children:p.active?O("g",{ref:p.group}):o?O("polygon",{points:o,transform:`translate(${c} ${u}) scale(${f} ${m})`,vectorEffect:"non-scaling-stroke"}):t?O("path",{d:t}):O("rect",{x:c,y:u,width:f,height:m})}),D("mask",{id:s+"-mask",maskUnits:"userSpaceOnUse",x:"0",y:"0",width:"100%",height:"100%",children:[O("rect",{width:"100%",height:"100%",fill:"white"}),O("use",{href:"#"+d,fill:"black"})]})]}),O("rect",{width:"100%",height:"100%",fill:"black",fillOpacity:.5,mask:`url(#${s}-mask)`}),r&&O("use",{href:"#"+d,fill:"none",stroke:r,strokeWidth:1,strokeDasharray:a?void 0:h})]})}var K,U=new Set;function Z(e){if(U.add(e),!K){let e=new Map,t=new Map,o="",n=!0,i=!0,r=!1,a=!0,l=0,s=()=>{let o=new Set,r=new Map,a=t=>{if(o.add(t),!e.has(t)){let o=new MutationObserver(e=>{let t=e.filter(e=>!(1===e.target.nodeType?e.target:e.target.parentElement)?.closest("[data-devtools]"));t.length&&(n=!0),t.some(e=>"childList"===e.type)&&(i=!0)});o.observe(t,{subtree:!0,childList:!0,characterData:!0,attributes:!0});let r=()=>{n=!0};t.addEventListener("scroll",r,!0),t.addEventListener("load",r,!0),e.set(t,()=>{o.disconnect(),t.removeEventListener("scroll",r,!0),t.removeEventListener("load",r,!0)})}for(let e of t.querySelectorAll("*")){if(e.shadowRoot&&!e.closest("[data-devtools]")&&a(e.shadowRoot),"iframe"!==e.localName||e.closest("[data-devtools],[data-popmelt-peer-surface]"))continue;let t=x(e);r.set(e,t),t&&a(t)}};a(document);for(let[t,n]of e)o.has(t)||(n(),e.delete(t));t=r,i=!1,n=!0},d=()=>{if(!a)return;(i||[...t].some(([e,t])=>x(e)!==t))&&s();let e=[];for(let[o,n]of t){let t=o.getBoundingClientRect();e.push(n?.URL,t.x,t.y,t.width,t.height,n?.defaultView?.scrollX,n?.defaultView?.scrollY)}let p=JSON.stringify(e);if((n||p!==o)&&(n=!1,o=p,r))for(let e of U)e();r=!0,a&&(l=requestAnimationFrame(d))};d(),K=()=>{a=!1,cancelAnimationFrame(l);for(let t of e.values())t()}}return()=>{U.delete(e),U.size||(K?.(),K=void 0)}}function Y(e,t,o){let n=e.ownerDocument.defaultView,i=new Set,r=new Set,a=null;function l(){a=null,o();for(let e of r)!e.pending&&"running"!==e.playState&&r.delete(e);r.size&&(a=n.requestAnimationFrame(l))}function s(e){for(let t of e.getAnimations?.()??[])(t.pending||"running"===t.playState)&&r.add(t);r.size&&null===a&&(a=n.requestAnimationFrame(l))}function d(e){e.target===e.currentTarget&&s(e.currentTarget)}let p=typeof ResizeObserver>"u"?null:new ResizeObserver(t),c=new MutationObserver(e=>{e.some(e=>Array.from(e.removedNodes).some(e=>i.has(e)))&&h(),e.some(e=>"style"===e.attributeName)?o():t()});function u(){c.disconnect(),p?.disconnect();for(let e of i)e.removeEventListener("animationstart",d),e.removeEventListener("transitionrun",d);i.clear(),r.clear(),null!==a&&n.cancelAnimationFrame(a),a=null}function h(){u();for(let t=e;t;t=t.assignedSlot??y(t))i.add(t),p?.observe(t),c.observe(t,{attributes:!0,attributeFilter:["style","class","hidden","open","data-popmelt-hover-painter"],childList:!0}),t.addEventListener("animationstart",d),t.addEventListener("transitionrun",d),s(t)}return h(),u}function _(n,i,r){let a=n.ownerDocument.defaultView??window,l=t(n)??n,s=()=>i(l),d=null,p=()=>{null===d&&(d=a.requestAnimationFrame(()=>{d=null,s()}))},c="true"===n.getAttribute("data-popmelt-subject-projection")&&r,u=()=>c?c.subscribeFrame(s):Y(l,p,s),h=u(),f=o(()=>{let e=t(n)??n;e!==l&&(h(),l=e,h=u(),s())}),g=e(s,a),v=m(n.ownerDocument)?Z(s):void 0;return s(),()=>{f(),v?.(),g(),h(),null!==d&&a.cancelAnimationFrame(d)}}function G(e){return"string"==typeof e?e:e.component+e.styles}function X(e,t){let o="string"==typeof e?0:16;return t(G(e))+o}function Q(e,t=!1){if(e.subjectLabel)return`<${e.subjectLabel}>`;let o=e.dataAttributes?.["data-popmelt-label"]?.trim();if(o)return o;if(t&&e.reactComponent)return{component:e.reactComponent,styles:""};let n=e.id?`#${e.id}`:"";if(t)return e.tagName+n;let i=(e.className?.match(/\S+/g)??[]).map(e=>e.replace(/^[\w.-]+[.-]module__[\w-]+?__([\w-]+)$/,"$1"));return e.reactComponent?{component:e.reactComponent,styles:i.length?` (${i.join(", ")})`:""}:[e.tagName+n,...i.slice(0,2)].join(".")}var J=400,ee=12,te=.24,oe=8,ne=4;function ie(e){return"string"==typeof e?8:4}function re(e){return{...d(),display:"flex",alignItems:"center",gap:4,backgroundColor:e,color:"#fff",fontSize:12,lineHeight:12*s+"px",fontFamily:l,letterSpacing:"0.24px",padding:"0 8px",borderRadius:8,whiteSpace:"nowrap",maxWidth:400}}var ae={overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0};function le({label:e,prefix:t="",hoverName:o,preview:n="expanded"}){let i="expanded"!==n,r="string"!=typeof e,a=r?e.component:o??e,l=r?e.styles:e.slice(a.length),s=void 0!==o&&!!l;return r||s?D("span",{"data-popmelt-snap-collapse":s&&"waiting"===n||void 0,"data-popmelt-collapsed":s?i:void 0,style:{display:s?"flex":"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r?"rgb(255 255 255 / 60%)":void 0},children:[D("span",{"data-popmelt-component-name":r||void 0,style:{color:"#fff",...s&&{flex:"none",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis"}},children:[t,r&&O(k,{"aria-hidden":"true",size:12,fill:"currentColor",stroke:"none",style:{display:"inline-block",verticalAlign:"-0.12em",marginRight:4}}),a]}),s?O("span",{className:"popmelt-collapsible-badge-detail","aria-hidden":i,children:O("span",{className:"popmelt-collapsible-badge-detail-inner",style:{paddingLeft:0,whiteSpace:"pre",maxWidth:400},children:l})}):l]}):t+e}var se={topLeft:"0px",topRight:"0px",bottomRight:"0px",bottomLeft:"0px"};function de(e,t){return e.radii.topLeft===t.radii.topLeft&&e.radii.topRight===t.radii.topRight&&e.radii.bottomRight===t.radii.bottomRight&&e.radii.bottomLeft===t.radii.bottomLeft&&e.outline===t.outline&&e.path===t.path&&!["left","top","width","height"].some(o=>e.frameClip?.[o]!==t.frameClip?.[o]||e.subjectBounds?.[o]!==t.subjectBounds?.[o])&&e.fragments.length===t.fragments.length&&e.fragments.every((e,o)=>{let n=t.fragments[o];return!!n&&e.left===n.left&&e.top===n.top&&e.width===n.width&&e.height===n.height})}function pe(e,t){if(!e.isConnected||!g(e.ownerDocument))return{fragments:[],radii:se};let o=v(e),i=b(o,e.ownerDocument);if(m(e.ownerDocument)&&(!i.width||!i.height))return{fragments:[],radii:se};let a=t&&m(e.ownerDocument)?b(new DOMRect(0,0,window.innerWidth,window.innerHeight),e.ownerDocument):void 0;if("true"===e.getAttribute("data-popmelt-subject-projection"))return{fragments:[{left:i.left,top:i.top,width:i.width,height:i.height}],radii:se,frameClip:a,subjectBounds:t?o:void 0,outline:e.getAttribute("data-popmelt-subject-outline")??void 0};let l=Array.from(e.getClientRects()).map(t=>b(w(t,e.ownerDocument),e.ownerDocument)).filter(e=>e.width>0&&e.height>0).map(e=>({left:e.left,top:e.top,width:e.width,height:e.height}));return{fragments:r(l.length>0?l:[{left:i.left,top:i.top,width:i.width,height:i.height}]),radii:n(e),path:t?u(e):void 0,frameClip:a}}function ce({element:e,projectedRect:o,isSelected:n=!1,elementInfo:r,color:l="#3b82f6",annotationNumber:s,changeCount:d,hideTooltip:u=!1,hideOutline:h=!1,hideFill:m=!1,tintHoveredSubject:g=!1,spotlight:v=!1,fillOpacity:b=.05,subjectRegistry:w,railGap:y=2,railHeight:x=22,railWidth:k=0,renderRail:R,refreshKey:C,outlineZIndex:S=9996,onActivate:z,onRemove:F}){let I=j(N);L(()=>{if(!(I&&g&&e&&w))return;let t=f(e);if(!t)return;let o=w.resolve(t);return o?.element===e?o.adapter.highlightHover?.(t.key,l):void 0},[e,l,w,g,I]);let[T,H]=$({fragments:[],radii:se});L(()=>{if(I)return e?_(e,e=>{let t=pe(e,v);H(e=>de(e,t)?e:t)},w):void H({fragments:[],radii:se})},[I,e,w,v]),L(()=>{if(!I||!e||void 0===C)return;let o=pe(t(e)??e,v);H(e=>de(e,o)?e:o)},[I,e,C,v]);let{fragments:V,radii:K}=o?{fragments:[o],radii:se}:T,U=e&&(t(e)??e),Z=U?.closest("[data-popmelt-hover-painter]"),[Y,G]=$(null);L(()=>{if(!I||o||h||v||!U||!Z)return void G(null);let e=p(U,l,m?0:b,n?"solid":"dashed");return G(e?U:null),()=>e?.abort()},[I,o,h,U,Z,l,m,v,b,n]);let X=!!U&&Y===U,J=M(!I||o||1!==V.length||T.outline?null:U),ee=J?W:void 0;if(0===V.length||!e&&!o)return null;let te=i(V,V[0]),oe=Q({tagName:e?.localName??"",id:e?.id,className:e?.getAttribute("class")??void 0,reactComponent:r?.reactComponent,subjectLabel:e?.hasAttribute("data-popmelt-subject-adapter")?e.getAttribute("data-popmelt-subject-label")??void 0:void 0,dataAttributes:{"data-popmelt-label":e?.getAttribute("data-popmelt-label")??""}}),ne=c({left:te.left,right:te.left+te.width,top:te.top,bottom:te.top+te.height,height:te.height},x,y,window.innerHeight,k,window.innerWidth),re={zIndex:9997,display:"flex",alignItems:"center",gap:6,backgroundColor:l,color:"#fff",fontSize:12,fontFamily:A,lineHeight:"14px",padding:"4px 8px",paddingLeft:void 0===s?ie(oe):8,borderRadius:8,pointerEvents:"none",whiteSpace:"nowrap",maxWidth:400,position:"fixed",...B(J,te,ne.left,ne.top)},ae=!u&&D("div",{ref:t=>{e&&a(e,t,ne.anchor)},part:ee,"data-devtools":"tooltip",style:re,children:[void 0!==s&&D("span",{children:[s,"."]}),O("span",{style:{overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:O(le,{label:oe})}),void 0!==d&&d>0&&D("span",{style:{opacity:.8},children:["(",d," ",1===d?"change":"changes",")"]})]}),ce={borderTopLeftRadius:K.topLeft,borderTopRightRadius:K.topRight,borderBottomRightRadius:K.bottomRight,borderBottomLeftRadius:K.bottomLeft};return D(E,{children:[v&&O(q,{painterTarget:I&&!o&&Z?U:null,path:o?void 0:T.path,polygon:o?void 0:T.outline,bounds:!o&&T.subjectBounds||te,clip:o?void 0:T.frameClip,color:h?void 0:l,selected:n,zIndex:S-1}),!h&&V.map((e,t)=>O("div",{part:ee,"data-devtools":"highlight",onContextMenu:F?e=>{e.preventDefault(),e.stopPropagation(),F()}:void 0,role:z?"button":void 0,tabIndex:z?0:void 0,"aria-label":z?"Open annotation thread":void 0,onPointerDown:z?e=>{e.preventDefault(),e.stopPropagation()}:void 0,onClick:z?e=>{e.preventDefault(),e.stopPropagation(),z()}:void 0,onKeyDown:z?e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),e.stopPropagation(),z())}:void 0,style:{position:"fixed",...B(J,te,e.left,e.top),width:e.width,height:e.height,pointerEvents:z||F?"auto":"none",cursor:z?"pointer":void 0,zIndex:S,overflow:"visible",opacity:X||v?0:void 0},children:O("div",{style:T.outline?{position:"absolute",inset:0,pointerEvents:"none"}:{position:"absolute",inset:0,boxSizing:"border-box",backgroundColor:m||v?"transparent":P(l,b),borderColor:l,borderStyle:n?"solid":"dashed",borderWidth:1,...ce,pointerEvents:"none"},children:T.outline?O("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%",style:{display:"block",overflow:"visible"},"aria-hidden":"true",children:O("polygon",{points:T.outline,fill:m||v?"transparent":P(l,b),stroke:l,strokeWidth:1,strokeDasharray:n?void 0:"4 3",vectorEffect:"non-scaling-stroke"})}):null})},t)),R?R(ne,te,J):ae]})}export{N as a,P as b,W as c,I as d,T as e,H as f,M as g,B as h,Z as i,_ as j,G as k,X as l,Q as m,J as n,ee as o,te as p,oe as q,ne as r,ie as s,re as t,ae as u,le as v,ce as w};
1
+ "use client";import{c as e}from"./chunk-RK6UROPO.mjs";import{o as t,n as o,h as n}from"./chunk-AOTDTBQO.mjs";import{j as i,k as r}from"./chunk-RWZ7SVMO.mjs";import{a}from"./chunk-HAZXZ5TU.mjs";import{h as l,e as s,o as d,X as p,v as c,A as u,b as h}from"./chunk-KF35YUNZ.mjs";import{b as m}from"./chunk-VBH2YQLG.mjs";import{a as f,h as g,d as v,i as b,c as w,m as y,b as x}from"./chunk-LH7HKUCK.mjs";import{L as k}from"./chunk-KE4MQBRY.mjs";import{b as A}from"./chunk-ADRWR5GI.mjs";import{createContext as R,useState as $,useLayoutEffect as L,useContext as j,useId as C,useRef as S}from"react";import{jsxs as D,jsx as E,Fragment as O}from"react/jsx-runtime";var N=R(!0);function z(e,t){let o=e.match(/^oklch\(([^)]+)\)$/i);if(o)return`oklch(${o[1]} / ${t})`;let n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n){return`rgba(${parseInt(n[1],16)}, ${parseInt(n[2],16)}, ${parseInt(n[3],16)}, ${t})`}return`color-mix(in srgb, ${e} ${Math.round(100*t)}%, transparent)`}var F=new WeakMap,P=0,T="popmelt-scroll-anchor",W="popmelt-page-paint",I=`\n[data-popmelt-top-layer-host]::part(${T}) {\n position-anchor: var(--popmelt-anchor) !important;\n}\n[data-popmelt-top-layer-host]::part(${W}) {\n position-anchor: --popmelt-page-origin;\n left: calc(anchor(left, calc(0px - var(--popmelt-painted-x, 0px))) + var(--popmelt-painted-x, 0px));\n top: calc(anchor(top, calc(0px - var(--popmelt-painted-y, 0px))) + var(--popmelt-painted-y, 0px));\n}\n`;function M(e){if(!(e instanceof HTMLElement&&e.getRootNode()===document&&globalThis.CSS?.supports?.("top","anchor(top)")))return;let t=F.get(e);if(!t){let o=getComputedStyle(e).getPropertyValue("anchor-name");if(o&&"none"!==o)return;let n="--popmelt-target-"+ ++P;t={name:n,users:0,previous:e.style.getPropertyValue("anchor-name"),priority:e.style.getPropertyPriority("anchor-name")},F.set(e,t),e.style.setProperty("anchor-name",n)}let o=t;return o.users++,{name:o.name,element:e,release(){--o.users||(F.delete(e),e.style.getPropertyValue("anchor-name")===o.name&&e.style.setProperty("anchor-name",o.previous,o.priority))}}}function H(e){let[t,o]=$();return L(()=>{let t=M(e);return o(t),t?.release},[e]),t&&t.element===e?t.name:void 0}function B(e,t,o,n){return e?{"--popmelt-anchor":e,positionAnchor:e,left:`calc(anchor(left, ${t.left}px) + ${o-t.left}px)`,top:`calc(anchor(top, ${t.top}px) + ${n-t.top}px)`}:{left:o,top:n}}function V(e){let[t,o]=$(null),n=S(null);return L(()=>{if(o(null),!e)return;let t=p(e,"transparent",0,"solid",o);return()=>t?.abort()},[e]),L(()=>{let e=n.current;if(!t||!e)return;let o=()=>{let o=t.matches("path")?[t]:t.querySelectorAll("path"),n=0;for(let t of o){let o=t.getAttribute("d"),i=t.getScreenCTM();if(!o||!i||!t.getClientRects().length)continue;let r=e.children[n++];r||(r=e.ownerDocument.createElementNS("http://www.w3.org/2000/svg","path"),r.setAttribute("vector-effect","non-scaling-stroke"),e.append(r));let a=f(t.ownerDocument)?w({left:0,top:0,width:1,height:1},t.ownerDocument):null,l=a?.width??1,s=a?.height??1,d=`matrix(${i.a*l} ${i.b*s} ${i.c*l} ${i.d*s} ${i.e*l+(a?.x??0)} ${i.f*s+(a?.y??0)})`;r.getAttribute("d")!==o&&r.setAttribute("d",o),r.getAttribute("transform")!==d&&r.setAttribute("transform",d);let p=t.getAttribute("fill-rule")||"nonzero";r.getAttribute("fill-rule")!==p&&r.setAttribute("fill-rule",p)}for(;e.children.length>n;)e.lastElementChild.remove()},i=new MutationObserver(o);i.observe(t,{subtree:!0,attributes:!0,childList:!0});let r,a=()=>{o(),r=requestAnimationFrame(a)};return a(),()=>{i.disconnect(),cancelAnimationFrame(r),e.replaceChildren()}},[t]),{active:!!t,group:n}}function q({painterTarget:e,path:t,polygon:o,bounds:n,clip:i,color:r,selected:a,zIndex:l}){let s=C(),d=s+"-contour",p=V(e),{left:c,top:u,width:m,height:f}=n;return D("svg",{"data-devtools":"sample-spotlight","aria-hidden":"true",width:"100%",height:"100%",style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:l},children:[D("defs",{children:[i&&E("clipPath",{id:s+"-clip",children:E("rect",{x:i.left,y:i.top,width:i.width,height:i.height})}),E("g",{id:d,clipPath:i?`url(#${s}-clip)`:void 0,children:p.active?E("g",{ref:p.group}):o?E("polygon",{points:o,transform:`translate(${c} ${u}) scale(${m} ${f})`,vectorEffect:"non-scaling-stroke"}):t?E("path",{d:t}):E("rect",{x:c,y:u,width:m,height:f})}),D("mask",{id:s+"-mask",maskUnits:"userSpaceOnUse",x:"0",y:"0",width:"100%",height:"100%",children:[E("rect",{width:"100%",height:"100%",fill:"white"}),E("use",{href:"#"+d,fill:"black"})]})]}),E("rect",{width:"100%",height:"100%",fill:"black",fillOpacity:.5,mask:`url(#${s}-mask)`}),r&&E("use",{href:"#"+d,fill:"none",stroke:r,strokeWidth:1,strokeDasharray:a?void 0:h})]})}var K,U=new Set;function Z(e){if(U.add(e),!K){let e=new Map,t=new Map,o="",n=!0,i=!0,r=!1,a=!0,l=0,s=()=>{let o=new Set,r=new Map,a=t=>{if(o.add(t),!e.has(t)){let o=new MutationObserver(e=>{let t=e.filter(e=>!(1===e.target.nodeType?e.target:e.target.parentElement)?.closest("[data-devtools]"));t.length&&(n=!0),t.some(e=>"childList"===e.type)&&(i=!0)});o.observe(t,{subtree:!0,childList:!0,characterData:!0,attributes:!0});let r=()=>{n=!0};t.addEventListener("scroll",r,!0),t.addEventListener("load",r,!0),e.set(t,()=>{o.disconnect(),t.removeEventListener("scroll",r,!0),t.removeEventListener("load",r,!0)})}for(let e of t.querySelectorAll("*")){if(e.shadowRoot&&!e.closest("[data-devtools]")&&a(e.shadowRoot),"iframe"!==e.localName||e.closest("[data-devtools],[data-popmelt-peer-surface]"))continue;let t=x(e);r.set(e,t),t&&a(t)}};a(document);for(let[t,n]of e)o.has(t)||(n(),e.delete(t));t=r,i=!1,n=!0},d=()=>{if(!a)return;(i||[...t].some(([e,t])=>x(e)!==t))&&s();let e=[];for(let[o,n]of t){let t=o.getBoundingClientRect();e.push(n?.URL,t.x,t.y,t.width,t.height,n?.defaultView?.scrollX,n?.defaultView?.scrollY)}let p=JSON.stringify(e);if((n||p!==o)&&(n=!1,o=p,r))for(let e of U)e();r=!0,a&&(l=requestAnimationFrame(d))};d(),K=()=>{a=!1,cancelAnimationFrame(l);for(let t of e.values())t()}}return()=>{U.delete(e),U.size||(K?.(),K=void 0)}}function Y(e,t,o){let n=e.ownerDocument.defaultView,i=new Set,r=new Set,a=null;function l(){a=null,o();for(let e of r)!e.pending&&"running"!==e.playState&&r.delete(e);r.size&&(a=n.requestAnimationFrame(l))}function s(e){for(let t of e.getAnimations?.()??[])(t.pending||"running"===t.playState)&&r.add(t);r.size&&null===a&&(a=n.requestAnimationFrame(l))}function d(e){e.target===e.currentTarget&&s(e.currentTarget)}let p=typeof ResizeObserver>"u"?null:new ResizeObserver(t),c=new MutationObserver(e=>{e.some(e=>Array.from(e.removedNodes).some(e=>i.has(e)))&&h(),e.some(e=>"style"===e.attributeName)?o():t()});function u(){c.disconnect(),p?.disconnect();for(let e of i)e.removeEventListener("animationstart",d),e.removeEventListener("transitionrun",d);i.clear(),r.clear(),null!==a&&n.cancelAnimationFrame(a),a=null}function h(){u();for(let t=e;t;t=t.assignedSlot??y(t))i.add(t),p?.observe(t),c.observe(t,{attributes:!0,attributeFilter:["style","class","hidden","open","data-popmelt-hover-painter"],childList:!0}),t.addEventListener("animationstart",d),t.addEventListener("transitionrun",d),s(t)}return h(),u}function _(n,i,r){let a=n.ownerDocument.defaultView??window,l=t(n)??n,s=()=>i(l),d=null,p=()=>{null===d&&(d=a.requestAnimationFrame(()=>{d=null,s()}))},c="true"===n.getAttribute("data-popmelt-subject-projection")&&r,u=()=>c?c.subscribeFrame(s):Y(l,p,s),h=u(),m=o(()=>{let e=t(n)??n;e!==l&&(h(),l=e,h=u(),s())}),g=e(s,a),v=f(n.ownerDocument)?Z(s):void 0;return s(),()=>{m(),v?.(),g(),h(),null!==d&&a.cancelAnimationFrame(d)}}function G(e){return"string"==typeof e?e:e.component+e.styles}function Q(e,t){let o="string"==typeof e?0:16;return t(G(e))+o}function X(e,t=!1){if(e.subjectLabel)return`<${e.subjectLabel}>`;let o=e.dataAttributes?.["data-popmelt-label"]?.trim();if(o)return o;if(t&&e.reactComponent)return{component:e.reactComponent,styles:""};let n=e.id?`#${e.id}`:"";if(t)return e.tagName+n;let i=(e.className?.match(/\S+/g)??[]).map(e=>e.replace(/^[\w.-]+[.-]module__[\w-]+?__([\w-]+)$/,"$1"));return e.reactComponent?{component:e.reactComponent,styles:i.length?` (${i.join(", ")})`:""}:[e.tagName+n,...i.slice(0,2)].join(".")}var J=400,ee=12,te=.24,oe=8,ne=4;function ie(e){return"string"==typeof e?8:4}function re(e){return{...d(),display:"flex",alignItems:"center",gap:4,backgroundColor:e,color:"#fff",fontSize:12,lineHeight:12*s+"px",fontFamily:l,letterSpacing:"0.24px",padding:"0 8px",borderRadius:8,whiteSpace:"nowrap",maxWidth:400}}var ae={overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0};function le({label:e,prefix:t="",hoverName:o,preview:n="expanded"}){let i="expanded"!==n,r="string"!=typeof e,a=r?e.component:o??e,l=r?e.styles:e.slice(a.length),s=void 0!==o&&!!l;return r||s?D("span",{"data-popmelt-snap-collapse":s&&"waiting"===n||void 0,"data-popmelt-collapsed":s?i:void 0,style:{display:s?"flex":"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r?"rgb(255 255 255 / 60%)":void 0},children:[D("span",{"data-popmelt-component-name":r||void 0,style:{color:"#fff",...s&&{flex:"none",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis"}},children:[t,r&&E(k,{"aria-hidden":"true",size:12,fill:"currentColor",stroke:"none",style:{display:"inline-block",verticalAlign:"-0.12em",marginRight:4}}),a]}),s?E("span",{className:"popmelt-collapsible-badge-detail","aria-hidden":i,children:E("span",{className:"popmelt-collapsible-badge-detail-inner",style:{paddingLeft:0,whiteSpace:"pre",maxWidth:400},children:l})}):l]}):t+e}var se={topLeft:"0px",topRight:"0px",bottomRight:"0px",bottomLeft:"0px"};function de(e,t){return e.radii.topLeft===t.radii.topLeft&&e.radii.topRight===t.radii.topRight&&e.radii.bottomRight===t.radii.bottomRight&&e.radii.bottomLeft===t.radii.bottomLeft&&e.outline===t.outline&&e.path===t.path&&!["left","top","width","height"].some(o=>e.frameClip?.[o]!==t.frameClip?.[o]||e.subjectBounds?.[o]!==t.subjectBounds?.[o])&&e.fragments.length===t.fragments.length&&e.fragments.every((e,o)=>{let n=t.fragments[o];return!!n&&e.left===n.left&&e.top===n.top&&e.width===n.width&&e.height===n.height})}function pe(e,t){if(!e.isConnected||!g(e.ownerDocument))return{fragments:[],radii:se};let o=v(e),i=b(o,e.ownerDocument);if(f(e.ownerDocument)&&(!i.width||!i.height))return{fragments:[],radii:se};let a=t&&f(e.ownerDocument)?b(new DOMRect(0,0,window.innerWidth,window.innerHeight),e.ownerDocument):void 0;if("true"===e.getAttribute("data-popmelt-subject-projection"))return{fragments:[{left:i.left,top:i.top,width:i.width,height:i.height}],radii:se,frameClip:a,subjectBounds:t?o:void 0,outline:e.getAttribute("data-popmelt-subject-outline")??void 0};let l=Array.from(e.getClientRects()).map(t=>b(w(t,e.ownerDocument),e.ownerDocument)).filter(e=>e.width>0&&e.height>0).map(e=>({left:e.left,top:e.top,width:e.width,height:e.height}));return{fragments:r(l.length>0?l:[{left:i.left,top:i.top,width:i.width,height:i.height}]),radii:n(e),path:t?u(e):void 0,frameClip:a}}function ce({element:e,projectedRect:o,isSelected:n=!1,elementInfo:r,color:l="#3b82f6",annotationNumber:s,changeCount:d,hideTooltip:u=!1,hideOutline:h=!1,hideFill:f=!1,tintHoveredSubject:g=!1,spotlight:v=!1,fillOpacity:b=.05,subjectRegistry:w,railGap:y=2,railHeight:x=22,railWidth:k=0,renderRail:R,refreshKey:C,outlineZIndex:S=9996,threadTarget:F,onActivate:P,onRemove:W}){let I=j(N);L(()=>{if(!(I&&g&&e&&w))return;let t=m(e);if(!t)return;let o=w.resolve(t);return o?.element===e?o.adapter.highlightHover?.(t.key,l):void 0},[e,l,w,g,I]);let[M,V]=$({fragments:[],radii:se});L(()=>{if(I)return e?_(e,e=>{let t=pe(e,v);V(e=>de(e,t)?e:t)},w):void V({fragments:[],radii:se})},[I,e,w,v]),L(()=>{if(!I||!e||void 0===C)return;let o=pe(t(e)??e,v);V(e=>de(e,o)?e:o)},[I,e,C,v]);let{fragments:K,radii:U}=o?{fragments:[o],radii:se}:M,Z=e&&(t(e)??e),Y=Z?.closest("[data-popmelt-hover-painter]"),[G,Q]=$(null);L(()=>{if(!I||o||h||v||!Z||!Y)return void Q(null);let e=p(Z,l,f?0:b,n?"solid":"dashed");return Q(e?Z:null),()=>e?.abort()},[I,o,h,Z,Y,l,f,v,b,n]);let J=!!Z&&G===Z,ee=H(!I||o||1!==K.length||M.outline?null:Z),te=ee?T:void 0;if(0===K.length||!e&&!o)return null;let oe=i(K,K[0]),ne=X({tagName:e?.localName??"",id:e?.id,className:e?.getAttribute("class")??void 0,reactComponent:r?.reactComponent,subjectLabel:e?.hasAttribute("data-popmelt-subject-adapter")?e.getAttribute("data-popmelt-subject-label")??void 0:void 0,dataAttributes:{"data-popmelt-label":e?.getAttribute("data-popmelt-label")??""}}),re=c({left:oe.left,right:oe.left+oe.width,top:oe.top,bottom:oe.top+oe.height,height:oe.height},x,y,window.innerHeight,k,window.innerWidth),ae={zIndex:9997,display:"flex",alignItems:"center",gap:6,backgroundColor:l,color:"#fff",fontSize:12,fontFamily:A,lineHeight:"14px",padding:"4px 8px",paddingLeft:void 0===s?ie(ne):8,borderRadius:8,pointerEvents:"none",whiteSpace:"nowrap",maxWidth:400,position:"fixed",...B(ee,oe,re.left,re.top)},ce=!u&&D("div",{ref:t=>{e&&a(e,t,re.anchor)},part:te,"data-devtools":"tooltip",style:ae,children:[void 0!==s&&D("span",{children:[s,"."]}),E("span",{style:{overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:E(le,{label:ne})}),void 0!==d&&d>0&&D("span",{style:{opacity:.8},children:["(",d," ",1===d?"change":"changes",")"]})]}),ue={borderTopLeftRadius:U.topLeft,borderTopRightRadius:U.topRight,borderBottomRightRadius:U.bottomRight,borderBottomLeftRadius:U.bottomLeft};return D(O,{children:[v&&E(q,{painterTarget:I&&!o&&Y?Z:null,path:o?void 0:M.path,polygon:o?void 0:M.outline,bounds:!o&&M.subjectBounds||oe,clip:o?void 0:M.frameClip,color:h?void 0:l,selected:n,zIndex:S-1}),!h&&K.map((e,t)=>E("div",{part:te,"data-devtools":"highlight",onContextMenu:W?e=>{e.preventDefault(),e.stopPropagation(),W()}:void 0,role:P?"button":void 0,tabIndex:P?0:void 0,"data-popmelt-thread-target":P&&F,"aria-label":P?"Open annotation thread":void 0,onPointerDown:P?e=>{e.preventDefault(),e.stopPropagation()}:void 0,onClick:P?e=>{e.preventDefault(),e.stopPropagation(),P()}:void 0,onKeyDown:P?e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),e.stopPropagation(),P())}:void 0,style:{position:"fixed",...B(ee,oe,e.left,e.top),width:e.width,height:e.height,pointerEvents:P||W?"auto":"none",cursor:P?"pointer":void 0,zIndex:S,overflow:"visible",opacity:J||v?0:void 0},children:E("div",{style:M.outline?{position:"absolute",inset:0,pointerEvents:"none"}:{position:"absolute",inset:0,boxSizing:"border-box",backgroundColor:f||v?"transparent":z(l,b),borderColor:l,borderStyle:n?"solid":"dashed",borderWidth:1,...ue,pointerEvents:"none"},children:M.outline?E("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%",style:{display:"block",overflow:"visible"},"aria-hidden":"true",children:E("polygon",{points:M.outline,fill:f||v?"transparent":z(l,b),stroke:l,strokeWidth:1,strokeDasharray:n?void 0:"4 3",vectorEffect:"non-scaling-stroke"})}):null})},t)),R?R(re,oe,ee):ce]})}export{N as a,z as b,T as c,W as d,I as e,M as f,H as g,B as h,Z as i,_ as j,G as k,Q as l,X as m,J as n,ee as o,te as p,oe as q,ne as r,ie as s,re as t,ae as u,le as v,ce as w};
@@ -1 +1 @@
1
- import{a as e,b as t}from"./chunk-CIKFUS7J.mjs";import{a as r,e as a,f as i,g as s}from"./chunk-K22VZV3V.mjs";import{a as n}from"./chunk-YMWXWXPV.mjs";import{c as o}from"./chunk-UIADZXVT.mjs";import{execFile as p}from"child_process";import{createHash as c}from"crypto";import{mkdir as l,mkdtemp as d,realpath as u,rm as h,stat as m}from"fs/promises";import{join as f,relative as w,resolve as g}from"path";import{promisify as y}from"util";var v=y(p),b=/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/;async function k(e,t,r){let a={...process.env};for(let e of Object.keys(a))e.startsWith("GIT_")&&delete a[e];async function i(e,t,r){return(await v("git",["-c","core.hooksPath=/dev/null","-c","user.name=Popmelt","-c","user.email=planes@localhost",...t],{cwd:e,env:r?{...a,GIT_INDEX_FILE:r}:a})).stdout.trim()}let s=await u(await i(e,["rev-parse","--show-toplevel"])),o=w(s,await u(e));await l(t,{recursive:!0,mode:448});let p=await u(t),y=w(s,p);if(!y.startsWith(".."+("win32"===process.platform?"\\":"/"))&&".."!==y&&!y.split(/[\\/]/).includes(".popmelt"))throw new Error("Store plane worktrees outside the checkout or under .popmelt.");let k="refs/popmelt/planes/"+c("sha256").update(s).digest("hex")+"/",P=await u(await i(s,["rev-parse","--path-format=absolute","--git-common-dir"])),I=new Map,j=new Map,E=new Map,S=new Map,R=e=>"edit-"+c("sha256").update(e).digest("hex");async function x(e){try{await m(f(e,".git"))}catch(e){if("ENOENT"===e.code)return null;throw e}let t=await u(e);if(t!==await u(await i(e,["rev-parse","--show-toplevel"]))||await u(await i(e,["rev-parse","--path-format=absolute","--git-common-dir"]))!==P)throw new Error("Plane checkout does not belong to this repository.");return g(t,o)}async function A(e){let t=E.get(e);if(t)return t;let a=await x(f(p,e))??(r&&e.startsWith("edit-")?await x(f(r,e)):null);return a&&E.set(e,a),a}async function H(e,t){if(!b.test(t))throw new Error("Unknown plane source snapshot.");let r=I.get(e);return r||(r=n(f(p,e+".lock"),async()=>{let r=await A(e);if(r)return r;let a=await i(s,["rev-parse","--verify",k+t+"^{commit}"]),n=f(p,e);return await i(s,["update-ref",k+"bases/"+e,a]),await i(s,["worktree","add","--quiet","--detach",n,a]),g(n,o)}).finally(()=>I.delete(e)),I.set(e,r)),r}return{capture:function(e=s){let t=j.get(e);return t||(t=async function(e){let t=e===s?s:await i(e,["rev-parse","--show-toplevel"]),r=await d(f(p,"index-"));try{let e=f(r,"index"),a=await i(t,["rev-parse","--verify","--quiet","HEAD"]).catch(e=>{if(1===e.code)return"";throw e});await i(t,["read-tree",a||"--empty"],e);let s=[":(glob)**/.popmelt/**",":(glob)**/.env",":(glob)**/.env.*",":(glob)**/node_modules/**"];await i(t,["rm","-rq","--cached","--ignore-unmatch","--",...s],e),await i(t,["add","-A","--",".",...s.map(e=>e.replace("(glob)","(exclude,glob)"))],e);let n=await i(t,["write-tree"],e),o=k+n;if(!await i(t,["rev-parse","--verify","--quiet",o]).catch(e=>{if(1===e.code)return"";throw e})){let e=await i(t,["commit-tree",n,...a?["-p",a]:[],"-m","Popmelt plane source"]);await i(t,["update-ref",o,e])}return n}finally{await h(r,{recursive:!0,force:!0})}}(e).finally(()=>j.delete(e)),j.set(e,t)),t},checkoutRoot:e=>g(e,w(g(s,o),s)),editable:(e,t)=>H(R(e),t),findEditable:e=>I.get(R(e))??A(R(e)),retained:e=>H("base-"+e,e),async basis(e){let t=S.get(e)??await i(s,["rev-parse",k+"bases/"+R(e)+"^{tree}"]);return S.set(e,t),t}}}import{createHash as P,createHmac as I,randomBytes as j}from"crypto";import{request as E}from"http";import{pipeline as S}from"stream/promises";var R="/popmelt/phone";var x=new Map;function A(t,r){let a=function(t,r){let a=_(t);if(!a)return r;let i=new Headers(r.headers);for(let[e,t]of Object.entries(a.headers))i.set(e,t);return{...r,headers:i,redirect:"error",credentials:a.phone?/^https:\/\/p-[0-9a-f]{32}\.popmelt\.com$/.test(location.origin)?"same-origin":"omit":a.pathPrefix===e+"/"?"same-origin":"omit"}}(t,r);if(_(t)?.phone){let e=new URL(t),r=new Headers(a.headers);return r.set("X-Popmelt-Phone-Route",e.pathname.slice(14)+e.search),fetch(e.origin+R,{...a,headers:r,cache:"no-store"})}return fetch(t,a)}function H(e,t){return typeof location<"u"&&e===location.origin+R&&!0===x.get(location.origin)?.phone&&x.get(location.origin)?.headers["X-Popmelt-Project-Id"]===t}function _(e){try{let t=new URL(e),r=x.get(t.origin);return r?.pathPrefix?("string"==typeof r.pathPrefix?[r.pathPrefix]:r.pathPrefix).some(e=>e.endsWith("/")?t.pathname.startsWith(e):t.pathname===e)?r:void 0:r}catch{return}}var q=class extends Error{constructor(e,t,r){super(t),this.status=e,this.code=r}},C=class{constructor(e,r,a,i=(...e)=>fetch(...e)){this.projectId=r,this.transport=i;let s=new URL(e);if(this.phone=H(e,r),!this.phone&&!t(e)&&("http:"!==s.protocol||!["localhost","127.0.0.1","[::1]"].includes(s.hostname)||s.username||s.password||s.search||s.hash||"/"!==s.pathname))throw new Error("Participant transport requires a local bridge origin");if(!r)throw new Error("Project identity required");this.base=this.phone||t(e)?e:s.origin,this.credential=a?{...a}:void 0}moderateStyles(e,t,r=!1){return this.rpc("moderate-styles",{participantId:e,styleModifications:t,restore:r})}moderateAnnotations(e,t,r=!1,a){return this.rpc("moderate-annotations",{participantId:e,annotationIds:t,restore:r,threadId:a})}async request(e,r,a={},i){let s=r instanceof FormData;if(this.phone&&!H(this.base,this.projectId))throw new Error("Phone pairing is no longer active");let n=await(this.phone?A:this.transport)(this.base+e,{method:"POST",redirect:"error",credentials:t(this.base)?"same-origin":"omit",signal:i??AbortSignal.timeout(3e4),headers:{...s?{}:{"Content-Type":"application/json"},"X-Popmelt-Project-Id":this.projectId,...this.credential&&!this.phone?{"X-Popmelt-Participant-Id":this.credential.participantId,"X-Popmelt-Participant-Token":this.credential.token}:{},...a},body:s?r:JSON.stringify(r)}),o=await n.json().catch(()=>null);if(!n.ok)throw new q(n.status,"string"==typeof o?.error?o.error:"Participant request failed","string"==typeof o?.code?o.code:void 0);if(null===o)throw new Error("Invalid participant response");return{data:o,status:n.status}}async rpc(e,t={},r){return(await this.request("/participants/"+e,t,{},r)).data}mountRequestScope(r){if(!this.credential)throw new Error("Join before mounting a canvas");return this.phone?()=>{}:function(r,a){let i=new URL(r);if(!t(r)&&("http:"!==i.protocol||!["localhost","127.0.0.1","[::1]"].includes(i.hostname)||"/"!==i.pathname||i.search||i.hash||i.username||i.password))throw new Error("Bridge scope requires a local origin");if(x.has(i.origin))throw new Error("This bridge already has an active participant in this page");let s={headers:{...a},pathPrefix:t(r)?e+"/":void 0};return x.set(i.origin,s),()=>{x.get(i.origin)===s&&x.delete(i.origin)}}(this.base,{"X-Popmelt-Project-Id":this.projectId,"X-Popmelt-Participant-Id":this.credential.participantId,"X-Popmelt-Participant-Token":this.credential.token,...r?{"X-Popmelt-Source-Revision":r.revision}:{}})}source(){return this.rpc("source")}snapshot(){return this.rpc("snapshot")}setHostModelSelection(e){return this.rpc("model-selection",{selection:e})}reserveAdmissionColor(e){return this.rpc("access-color",{receipt:e})}requestAdmission(e,t,r){return this.rpc("access-request",{receipt:e,name:t,colorIdentity:r})}admissionStatus(e){return this.rpc("access-status",{receipt:e})}cancelAdmission(e){return this.rpc("access-cancel",{receipt:e})}admissions(){return this.rpc("access-list")}decideAdmission(e,t){return this.rpc("access-decide",{id:e,decision:t})}attention(){return this.rpc("attention-read")}async reportAttention(e,t,r,a,i){return(await this.request("/participants/attention",{runtime:e,phase:t,operationId:r,location:a},{},i??AbortSignal.timeout(1500))).data}invite(){return this.rpc("invite")}guestInvite(e,t=(typeof location>"u"?"/":location.pathname)){return this.rpc("guest-invite",{mode:e,pathname:t},AbortSignal.timeout("tunnel"===e?18e4:6e4))}revokeInvite(e){return this.rpc("revoke-invite",{invitation:e})}join(e,t,r){return this.rpc("join",{invitation:e,name:t,...r?{colorIdentity:r}:{}})}joinOrRequestAdmission(e,t,r){return this.rpc("join-or-request",{invitation:e,name:t,colorIdentity:r})}read(e,t,r=!1){return this.rpc("read",{participantId:e,historyVersion:2,...r&&{ownSource:!0}},t)}connect(e,t){return this.rpc("connect",{runtimeId:e,previousToken:t})}renew(e,t){return this.rpc("renew",{runtime:e,activeColor:t})}disconnect(e){return this.rpc("disconnect",{runtime:e})}publish(e,t,r,a){return r.sourceId!==this.projectId?Promise.reject(new Error("Source world mismatch")):this.rpc("publish",{runtime:e,expectedRevision:t,sourceRevision:r.revision,state:a})}merge(e,t,r,a){return r.sourceId!==this.projectId?Promise.reject(new Error("Source world mismatch")):this.rpc("merge",{runtime:e,expectedRevision:t,sourceRevision:r.revision,events:a,historyVersion:2})}rename(e){return this.rpc("rename",{name:e})}setProjectVisibility(e){return this.rpc("project-visibility",{visibility:e})}setPermission(e,t){return this.rpc("permission",{participantId:e,permission:t})}revokeAccess(e){return this.rpc("revoke-access",{participantId:e})}pending(){return this.rpc("pending")}preview(e){return this.rpc("preview-read",{participantId:e})}previewWanted(e){return this.rpc("preview-demand",{runtime:e})}publishPreview(e,t,r){return this.rpc("preview-publish",{runtime:e,image:t,geometry:r})}review(e){return this.rpc("review",{id:e})}discard(e){return this.rpc("discard",{id:e})}submission(e,t){if(202===t&&!0===e.pendingApproval&&"string"==typeof e.submissionId)return{status:"pending-approval",submissionId:e.submissionId,threadId:"string"==typeof e.threadId?e.threadId:void 0};if(200===t&&"string"==typeof e.jobId&&"string"==typeof e.threadId&&"number"==typeof e.position)return{...e,status:"queued",jobId:e.jobId,threadId:e.threadId,position:e.position};throw new Error("Unexpected participant submission response")}async send(e,t,r){if(r.sourceId!==this.projectId)throw new Error("Source world mismatch");let a=await this.request("/send",e,{"X-Popmelt-Draft-Revision":String(t),"X-Popmelt-Source-Revision":r.revision});return this.submission(a.data,a.status)}contribute(e,t){return this.rpc("contribute",{threadId:e,text:t})}async approve(e,t){let r=await this.request("/participants/approve",{id:e,revision:t});return this.submission(r.data,r.status)}};async function O(e){let t,n=await k(e.projectRoot,e.directory,e.previousDirectory),p=new Map,c=new Map,l=new Map,d=new Map,u=j(32),h="",m=!1,f=!0,w=0,g=async()=>{let e=w,t=await n.capture();return h=t,e===w&&(f=!1),t};async function y(r){let i=l.get(r.id)||"/";if(r.id===await t){let e=await b();return{basePath:"/",path:i,version:e,basis:e}}let s=await n.findEditable(r.id),o="unversioned"===r.revision?void 0:r.revision;if(!s){let e=await b();if(!o||o===e)return{basePath:"/",path:i,version:e,basis:e}}let d=s||await n.retained(o),u=s?await n.basis(r.id):o,{basePath:h,app:f}=await async function(t,r){if(m)throw new Error("Plane session closed");let i=[...c.entries()].find(([,e])=>e.directory===t)?.[0];i||(i=a+"app/"+j(16).toString("hex")+"/",c.set(i,{directory:t,revision:r}));let s=p.get(t);if(!s){let a=i;s=e.startApp({directory:t,basePath:a,checkoutRoot:n.checkoutRoot(t),sourceRevision:r}).then(async e=>{let t;try{t=new URL(e.origin)}catch(t){throw await e.close(),t}if("http:"!==t.protocol||"127.0.0.1"!==t.hostname||t.origin!==e.origin)throw await e.close(),new Error("Plane app must serve a dedicated loopback origin");return c.get(a).app=e,e}).catch(e=>{throw p.delete(t),c.delete(a),e}),p.set(t,s)}let o=await s;return await(o.ready?.()),{basePath:i,app:o}}(d,u);return{basePath:h,path:i,version:f.version?.()||u,basis:u}}async function v(t,a,i,n,o){let p=t.planeAppBasis;if(!p)throw new Error("Participant plane authorization unavailable");let c,d=a.participantId,u=new C("http://127.0.0.1:"+t.port,t.projectId,a),h=await p(a,i);if(void 0!==n){if(d!==i||"string"!=typeof n||!/^\/(?!\/)/.test(n)||/[?#\\]/.test(n))throw new r(400,"Invalid plane route");let e=s(new URL(n,"http://localhost").pathname);if(e.startsWith("//")||e.startsWith("/__popmelt/"))throw new r(400,"Invalid plane route");c=e,!1!==o&&l.set(d,e)}let m={...await y(h),...e.interactivePage&&{interactivePage:!0}};c&&(m.path=c);let f=void 0===n?await u.read(i):{author:{id:d}};if((await p(a,i)).revision!==h.revision)throw new r(503,"Plane changed during selection");return{...f,application:m}}async function b(){return f||!h?g():h}return{capture:g,hostWorkspace:async()=>({revision:await b(),basePath:"/"}),hostBasis:b,open:v,checkout(t){if("/"===t)return e.projectRoot;let a=c.get(t);if(!a)throw new r(404,"Plane unavailable");return a.directory},async pageReader(e){let t=c.get(e);if(!t)throw new r(404,"Plane unavailable");let a=await p.get(t.directory);return await(a?.ready?.()),a?.pageReader},sourceChanged(){w++,f=!0},async servedAt(e){let t=c.get(i(e));if(!t){let e=await b();return{revision:e,appVersion:e}}let r=(await p.get(t.directory))?.version?.();return{revision:t.revision,appVersion:r??t.revision}},localPreview(e){for(let[t,r]of c)if(r.directory===e&&r.app)return{origin:r.app.origin,basePath:r.app.pageReader?"/":t}},findEditable:n.findEditable,forEdit:async(r,a,i=!1)=>i||r===await t?e.projectRoot:await n.findEditable(r)||n.editable(r,"unversioned"===a?await b():a),middleware(e,n,l){let h=new URL(n);if(!["127.0.0.1","localhost","[::1]"].includes(h.hostname)||h.origin!==n)throw new Error("Participant plane apps require a local app origin");t=e.participantHost?.().then(e=>e.participantId);let f=e.planeAppBasis;if(!f)throw new Error("Plane apps require a local participant bridge.");let w="popmelt-plane-"+P("sha256").update(e.projectId).digest("hex").slice(0,12);return async(t,g,y)=>{let b=t.url??"";if(!b.startsWith(a)){if(!b.startsWith("/")||b.startsWith("//")||b.startsWith("/__popmelt/")||!t.headers.referer||t.headers.host!==h.host||["document","iframe"].includes(String(t.headers["sec-fetch-dest"])))return y();let e;try{e=new URL(t.headers.referer)}catch{return y()}let r=e.origin===n&&i(e.pathname);return r&&c.has(r)?(g.setHeader("Cache-Control","private, no-store"),g.setHeader("Vary","Referer"),"GET"!==t.method&&"HEAD"!==t.method?(g.statusCode=405,void g.end()):(g.writeHead(307,{Location:r.slice(0,-1)+b}),void g.end())):y()}g.setHeader("Cache-Control","private, no-store"),g.setHeader("Referrer-Policy","same-origin"),g.setHeader("Cross-Origin-Resource-Policy","same-origin");let k=e=>{g.destroyed||g.writableEnded||(g.headersSent||(g.statusCode=e),g.end())};if(m||t.headers.host!==h.host||"cross-site"===t.headers["sec-fetch-site"])return k(403);try{if(b===a+"open"){if("POST"!==t.method||t.headers.origin!==n||"application/json"!==t.headers["content-type"])return k(403);let r=t.headers["x-popmelt-participant-id"],i=t.headers["x-popmelt-participant-token"];if("string"!=typeof r||"string"!=typeof i)return k(403);let s,o="";for await(let e of t)if(o+=e,o.length>8192)return k(413);try{s=JSON.parse(o)}catch{return k(400)}let{target:p,pathname:c,active:h}=s??{};if("string"!=typeof p)return k(400);let m={participantId:r,token:i},f=await v(e,m,p,c,h),{application:y}=f,b=I("sha256",u).update(i).digest("hex"),P=Date.now();for(let[e,t]of d)t.expires<=P&&d.delete(e);let j=d.get(b)??{proof:m,mounts:new Map,pages:new Map,expires:0};j.expires=P+36e5;let E=j.mounts.get(y.basePath)??new Set;if(E.add(p),l){let e=j.pages.get(y.basePath)??{routes:new Set,assets:new Set};e.routes.add(y.path),j.pages.set(y.basePath,e)}return j.mounts.set(y.basePath,E),d.set(b,j),g.setHeader("Set-Cookie",w+"="+b+"; Path="+a+"app/; HttpOnly; SameSite=Strict; Max-Age=3600"),g.setHeader("Content-Type","application/json"),void g.end(JSON.stringify(f))}if("GET"!==t.method&&"HEAD"!==t.method)return k(405);let h=new URL(b,n).pathname,m=i(h),y=m&&c.get(m);if("/"===m)return k(404);let P=t.headers.cookie?.split(";").map(e=>e.trim()).find(e=>e.startsWith(w+"="))?.slice(w.length+1),j=P&&d.get(P);if(!y||!j||j.expires<=Date.now()||!j.mounts.has(m)){if("document"===t.headers["sec-fetch-dest"]&&"navigate"===t.headers["sec-fetch-mode"]){let e=s(h);if(!e.startsWith("//")&&!e.startsWith("/__popmelt/"))return g.writeHead(302,{Location:e+new URL(b,n).search}),void g.end()}return k(y?403:404)}let R=j.mounts.get(m);for(let e of R)try{await f(j.proof,e);break}catch(t){if(!(t instanceof r)||404!==t.statusCode)throw t;R.delete(e)}if(!R.size)return k(404);let x=s(h),A=j.pages.get(m)?.routes,H=A?.has(x)?x:o(x),_=A?.has(H),q=["document","iframe"].includes(String(t.headers["sec-fetch-dest"]))||!!t.headers.accept?.includes("text/html")||"HEAD"===t.method&&!0===_,C=await p.get(y.directory);if(!C)return k(503);if(await(C.ready?.()),C.pageReader&&l){let r=new URL(b,n),a=j.pages.get(m);if(!a)return k(403);if(q&&!a.routes.has(H))return k(404);let i=await C.pageReader({url:r,document:q,sharedPath:H,basePath:m,assets:a.assets,projectId:e.projectId,bootstrap:await l(h)});return i?(g.statusCode=i.status,i.headers.forEach((e,t)=>g.setHeader(t,e)),void g.end("HEAD"===t.method?void 0:Buffer.from(await i.arrayBuffer()))):k(404)}let O=E(new URL(b,C.origin),{method:t.method,headers:{accept:t.headers.accept||"*/*"}});O.setTimeout(3e4,()=>O.destroy(new Error("Plane app timed out"))),g.on("close",()=>O.destroy()),O.on("error",()=>k(502)),O.on("response",e=>{g.statusCode=e.statusCode??502;let t=e.headers["content-type"];if(t&&g.setHeader("Content-Type",t),e.headers.location){let t;try{t=new URL(e.headers.location,new URL(b,C.origin))}catch{return e.resume(),k(502)}if(t.origin!==C.origin||!t.pathname.startsWith(m))return e.resume(),k(502);g.setHeader("Location",t.pathname+t.search)}S(e,g).catch(()=>g.destroy())}),O.end()}catch(e){let t=e instanceof r?e.statusCode:e instanceof q?e.status:void 0;k(t&&t>=400&&t<500?t:503)}}},async close(){m=!0,d.clear();let e=(await Promise.allSettled([...p.values()].map(async e=>(await e).close()))).find(e=>"rejected"===e.status);if("rejected"===e?.status)throw e.reason}}}import{execFile as W}from"child_process";import{createHash as L}from"crypto";import{lstat as M,mkdir as U,readFile as D,realpath as T,writeFile as X}from"fs/promises";import{basename as N,dirname as B,join as V,relative as J}from"path";import{promisify as F}from"util";var z=F(W),K={"npm-shrinkwrap.json":"npm","package-lock.json":"npm","pnpm-lock.yaml":"pnpm","yarn.lock":"yarn","bun.lock":"bun","bun.lockb":"bun"},G=[...Object.keys(K),"pnpm-workspace.yaml",".npmrc",".yarnrc.yml",".pnpmfile.cjs","bunfig.toml"],Z=["dependencies","devDependencies","optionalDependencies","peerDependencies","peerDependenciesMeta","overrides","resolutions","pnpm","workspaces","packageManager","dependenciesMeta","bundledDependencies","bundleDependencies","engines","os","cpu"];function $(e){let t=N(e);return"package.json"===t||G.includes(t)}async function Y(e){try{return await e}catch(e){if("ENOENT"!==e.code)throw e}}function Q(e,t){return!t||"object"!=typeof t||Array.isArray(t)?t:Object.fromEntries(Object.entries(t).sort(([e],[t])=>e<t?-1:e>t?1:0))}async function ee(e,t,r){let a,i;for(let r=e;;r=B(r)){let e=await Y(D(V(r,"package.json"),"utf8")),s=await Promise.all([...Object.keys(K),"pnpm-workspace.yaml"].map(e=>Y(M(V(r,e)))));if(e&&(a??=r),s.some(Boolean)||e&&JSON.parse(e).workspaces){i=r;break}if(r===t)break}if(i??=a,!i)return;let s=JSON.parse(await Y(D(V(i,"package.json"),"utf8"))??"{}"),n=L("sha256"),o=L("sha256"),p=await Promise.all(G.map(async e=>[e,await Y(D(V(i,e)))])),c=new Set;for(let[e,t]of p){if(!t)continue;c.add(e);let r=L("sha256").update(t).digest();n.update(e+"\0").update(r),e in K||o.update(e+"\0").update(r)}let l=!!s.workspaces||c.has("pnpm-workspace.yaml"),d=new Set(["package.json",J(i,V(e,"package.json"))]);if(l){let{stdout:e}=await z("git",["ls-files","--cached","--others","--exclude-standard","-z","--",":(glob)**/package.json",":(exclude,glob)**/node_modules/**",":(exclude,glob)**/.popmelt/**"],{cwd:i,maxBuffer:16777216});for(let t of e.split("\0").filter(Boolean))d.add(t)}for(let e of[...d].sort()){let t=await Y(D(V(i,e),"utf8"));if(!t)continue;let r=JSON.parse(t),a=l?[...Z,"name","version"]:Z,s=Object.fromEntries(a.filter(e=>e in r).map(e=>[e,r[e]]));o.update(e+"\0").update(JSON.stringify(s,Q)+"\0")}let u=new Set(Object.entries(K).filter(([e])=>c.has(e)).map(([,e])=>e));c.has("pnpm-workspace.yaml")&&u.add("pnpm");let h=s.packageManager?.split("@")[0]??(u.size>1?"ambiguous":[...u][0])??"npm",m=o.update(h).digest("hex");return n.update(m),r&&i!==e&&r([...d,...G].map(e=>V(i,e))),{root:i,key:n.digest("hex"),manifestKey:m,manager:h,pnpmWorkspace:c.has("pnpm-workspace.yaml"),manifests:d,present:c}}async function te(e,t,r,a){let i=V(r,J(e,t)),[s,o]=await Promise.all([ee(e,t),ee(r,i,a)]);if(!s)return{installed:!1,graph:"shared"};let p=V(s.root,"node_modules"),c=V(p,".popmelt-install"),l=await Y(D(c,"utf8"));return l===s.key?{installed:!1,graph:"private:"+s.key}:s.key===o?.key&&void 0===l?{installed:!1,graph:"shared:"+s.key}:n(V(t,".popmelt","dependencies.lock"),async()=>{let r=await ee(e,t);if(!r)return{installed:!1,graph:"shared"};let a=V(r.root,"node_modules",".popmelt-install");if(await Y(D(a,"utf8"))===r.key)return{installed:!1,graph:"private:"+r.key};for(let e of[...r.manifests,...r.present]){let t=V(r.root,e),a=await Y(T(t));if(a&&a!==t)throw new Error("Automatic plane installation requires local dependency files: "+e)}await async function(e){for(let t of e.manifests){let r=V(e.root,B(t),"node_modules"),a=await Y(M(r));if(a&&(a.isSymbolicLink()||await T(r)!==r))throw new Error("Plane node_modules points outside its install directory. Use a custom prepare hook.")}let t,r=e.root,a={...process.env,CI:"true",npm_config_global:"false"};switch(e.manager){case"npm":t=["install","--prefix",".","--ignore-scripts","--no-audit","--no-fund","--include=dev"];break;case"pnpm":t=["install","--ignore-scripts","--no-frozen-lockfile","--config.modules-dir=node_modules","--config.virtual-store-dir=node_modules/.pnpm",...e.pnpmWorkspace?[]:["--ignore-workspace"]];break;default:throw new Error("Automatic plane installs require npm or pnpm. Configure participantPlanes.prepare for "+e.manager+".")}await U(V(r,"node_modules"),{recursive:!0}),await X(V(r,"node_modules",".popmelt-install"),"pending"),await z(e.manager,t,{cwd:r,env:a,shell:"win32"===process.platform,timeout:18e4,maxBuffer:4194304})}(r);let i=await ee(e,t);if(!i||r.root!==i.root||r.manifestKey!==i.manifestKey)throw new Error("Plane dependencies changed during installation. Retry with the current manifest.");return await U(V(i.root,"node_modules"),{recursive:!0}),await X(V(i.root,"node_modules",".popmelt-install"),i.key),{installed:!0,graph:"private:"+i.key}},185e3)}export{k as a,O as b,$ as c,te as d};
1
+ import{a as e,b as t}from"./chunk-CIKFUS7J.mjs";import{a as r,e as a,f as i,g as s}from"./chunk-GLF7Z5IR.mjs";import{a as n}from"./chunk-KD2AOPYP.mjs";import{c as o}from"./chunk-KF73S7MG.mjs";import{execFile as p}from"child_process";import{createHash as c}from"crypto";import{mkdir as l,mkdtemp as d,realpath as u,rm as h,stat as m}from"fs/promises";import{join as f,relative as w,resolve as g}from"path";import{promisify as y}from"util";var v=y(p),b=/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/;async function k(e,t,r){let a={...process.env};for(let e of Object.keys(a))e.startsWith("GIT_")&&delete a[e];async function i(e,t,r){return(await v("git",["-c","core.hooksPath=/dev/null","-c","user.name=Popmelt","-c","user.email=planes@localhost",...t],{cwd:e,env:r?{...a,GIT_INDEX_FILE:r}:a})).stdout.trim()}let s=await u(await i(e,["rev-parse","--show-toplevel"])),o=w(s,await u(e));await l(t,{recursive:!0,mode:448});let p=await u(t),y=w(s,p);if(!y.startsWith(".."+("win32"===process.platform?"\\":"/"))&&".."!==y&&!y.split(/[\\/]/).includes(".popmelt"))throw new Error("Store plane worktrees outside the checkout or under .popmelt.");let k="refs/popmelt/planes/"+c("sha256").update(s).digest("hex")+"/",P=await u(await i(s,["rev-parse","--path-format=absolute","--git-common-dir"])),I=new Map,j=new Map,E=new Map,S=new Map,R=e=>"edit-"+c("sha256").update(e).digest("hex");async function x(e){try{await m(f(e,".git"))}catch(e){if("ENOENT"===e.code)return null;throw e}let t=await u(e);if(t!==await u(await i(e,["rev-parse","--show-toplevel"]))||await u(await i(e,["rev-parse","--path-format=absolute","--git-common-dir"]))!==P)throw new Error("Plane checkout does not belong to this repository.");return g(t,o)}async function A(e){let t=E.get(e);if(t)return t;let a=await x(f(p,e))??(r&&e.startsWith("edit-")?await x(f(r,e)):null);return a&&E.set(e,a),a}async function H(e,t){if(!b.test(t))throw new Error("Unknown plane source snapshot.");let r=I.get(e);return r||(r=n(f(p,e+".lock"),async()=>{let r=await A(e);if(r)return r;let a=await i(s,["rev-parse","--verify",k+t+"^{commit}"]),n=f(p,e);return await i(s,["update-ref",k+"bases/"+e,a]),await i(s,["worktree","add","--quiet","--detach",n,a]),g(n,o)}).finally(()=>I.delete(e)),I.set(e,r)),r}return{capture:function(e=s){let t=j.get(e);return t||(t=async function(e){let t=e===s?s:await i(e,["rev-parse","--show-toplevel"]),r=await d(f(p,"index-"));try{let e=f(r,"index"),a=await i(t,["rev-parse","--verify","--quiet","HEAD"]).catch(e=>{if(1===e.code)return"";throw e});await i(t,["read-tree",a||"--empty"],e);let s=[":(glob)**/.popmelt/**",":(glob)**/.env",":(glob)**/.env.*",":(glob)**/node_modules/**"];await i(t,["rm","-rq","--cached","--ignore-unmatch","--",...s],e),await i(t,["add","-A","--",".",...s.map(e=>e.replace("(glob)","(exclude,glob)"))],e);let n=await i(t,["write-tree"],e),o=k+n;if(!await i(t,["rev-parse","--verify","--quiet",o]).catch(e=>{if(1===e.code)return"";throw e})){let e=await i(t,["commit-tree",n,...a?["-p",a]:[],"-m","Popmelt plane source"]);await i(t,["update-ref",o,e])}return n}finally{await h(r,{recursive:!0,force:!0})}}(e).finally(()=>j.delete(e)),j.set(e,t)),t},checkoutRoot:e=>g(e,w(g(s,o),s)),editable:(e,t)=>H(R(e),t),findEditable:e=>I.get(R(e))??A(R(e)),retained:e=>H("base-"+e,e),async basis(e){let t=S.get(e)??await i(s,["rev-parse",k+"bases/"+R(e)+"^{tree}"]);return S.set(e,t),t}}}import{createHash as P,createHmac as I,randomBytes as j}from"crypto";import{request as E}from"http";import{pipeline as S}from"stream/promises";var R="/popmelt/phone";var x=new Map;function A(t,r){let a=function(t,r){let a=_(t);if(!a)return r;let i=new Headers(r.headers);for(let[e,t]of Object.entries(a.headers))i.set(e,t);return{...r,headers:i,redirect:"error",credentials:a.phone?/^https:\/\/p-[0-9a-f]{32}\.popmelt\.com$/.test(location.origin)?"same-origin":"omit":a.pathPrefix===e+"/"?"same-origin":"omit"}}(t,r);if(_(t)?.phone){let e=new URL(t),r=new Headers(a.headers);return r.set("X-Popmelt-Phone-Route",e.pathname.slice(14)+e.search),fetch(e.origin+R,{...a,headers:r,cache:"no-store"})}return fetch(t,a)}function H(e,t){return typeof location<"u"&&e===location.origin+R&&!0===x.get(location.origin)?.phone&&x.get(location.origin)?.headers["X-Popmelt-Project-Id"]===t}function _(e){try{let t=new URL(e),r=x.get(t.origin);return r?.pathPrefix?("string"==typeof r.pathPrefix?[r.pathPrefix]:r.pathPrefix).some(e=>e.endsWith("/")?t.pathname.startsWith(e):t.pathname===e)?r:void 0:r}catch{return}}var q=class extends Error{constructor(e,t,r){super(t),this.status=e,this.code=r}},O=class{constructor(e,r,a,i=(...e)=>fetch(...e)){this.projectId=r,this.transport=i;let s=new URL(e);if(this.phone=H(e,r),!this.phone&&!t(e)&&("http:"!==s.protocol||!["localhost","127.0.0.1","[::1]"].includes(s.hostname)||s.username||s.password||s.search||s.hash||"/"!==s.pathname))throw new Error("Participant transport requires a local bridge origin");if(!r)throw new Error("Project identity required");this.base=this.phone||t(e)?e:s.origin,this.credential=a?{...a}:void 0}moderateStyles(e,t,r=!1){return this.rpc("moderate-styles",{participantId:e,styleModifications:t,restore:r})}moderateAnnotations(e,t,r=!1,a){return this.rpc("moderate-annotations",{participantId:e,annotationIds:t,restore:r,threadId:a})}async request(e,r,a={},i){let s=r instanceof FormData;if(this.phone&&!H(this.base,this.projectId))throw new Error("Phone pairing is no longer active");let n=await(this.phone?A:this.transport)(this.base+e,{method:"POST",redirect:"error",credentials:t(this.base)?"same-origin":"omit",signal:i??AbortSignal.timeout(3e4),headers:{...s?{}:{"Content-Type":"application/json"},"X-Popmelt-Project-Id":this.projectId,...this.credential&&!this.phone?{"X-Popmelt-Participant-Id":this.credential.participantId,"X-Popmelt-Participant-Token":this.credential.token}:{},...a},body:s?r:JSON.stringify(r)}),o=await n.json().catch(()=>null);if(!n.ok)throw new q(n.status,"string"==typeof o?.error?o.error:"Participant request failed","string"==typeof o?.code?o.code:void 0);if(null===o)throw new Error("Invalid participant response");return{data:o,status:n.status}}async rpc(e,t={},r){return(await this.request("/participants/"+e,t,{},r)).data}mountRequestScope(r){if(!this.credential)throw new Error("Join before mounting a canvas");return this.phone?()=>{}:function(r,a){let i=new URL(r);if(!t(r)&&("http:"!==i.protocol||!["localhost","127.0.0.1","[::1]"].includes(i.hostname)||"/"!==i.pathname||i.search||i.hash||i.username||i.password))throw new Error("Bridge scope requires a local origin");if(x.has(i.origin))throw new Error("This bridge already has an active participant in this page");let s={headers:{...a},pathPrefix:t(r)?e+"/":void 0};return x.set(i.origin,s),()=>{x.get(i.origin)===s&&x.delete(i.origin)}}(this.base,{"X-Popmelt-Project-Id":this.projectId,"X-Popmelt-Participant-Id":this.credential.participantId,"X-Popmelt-Participant-Token":this.credential.token,...r?{"X-Popmelt-Source-Revision":r.revision}:{}})}source(){return this.rpc("source")}snapshot(){return this.rpc("snapshot")}setHostModelSelection(e){return this.rpc("model-selection",{selection:e})}reserveAdmissionColor(e){return this.rpc("access-color",{receipt:e})}requestAdmission(e,t,r){return this.rpc("access-request",{receipt:e,name:t,colorIdentity:r})}admissionStatus(e){return this.rpc("access-status",{receipt:e})}cancelAdmission(e){return this.rpc("access-cancel",{receipt:e})}admissions(){return this.rpc("access-list")}decideAdmission(e,t){return this.rpc("access-decide",{id:e,decision:t})}attention(){return this.rpc("attention-read")}async reportAttention(e,t,r,a,i){return(await this.request("/participants/attention",{runtime:e,phase:t,operationId:r,location:a},{},i??AbortSignal.timeout(1500))).data}invite(){return this.rpc("invite")}guestInvite(e,t=(typeof location>"u"?"/":location.pathname)){return this.rpc("guest-invite",{mode:e,pathname:t},AbortSignal.timeout("tunnel"===e?18e4:6e4))}revokeInvite(e){return this.rpc("revoke-invite",{invitation:e})}join(e,t,r){return this.rpc("join",{invitation:e,name:t,...r?{colorIdentity:r}:{}})}joinOrRequestAdmission(e,t,r){return this.rpc("join-or-request",{invitation:e,name:t,colorIdentity:r})}read(e,t,r=!1){return this.rpc("read",{participantId:e,historyVersion:2,...r&&{ownSource:!0}},t)}connect(e,t){return this.rpc("connect",{runtimeId:e,previousToken:t})}renew(e,t){return this.rpc("renew",{runtime:e,activeColor:t})}disconnect(e){return this.rpc("disconnect",{runtime:e})}publish(e,t,r,a){return r.sourceId!==this.projectId?Promise.reject(new Error("Source world mismatch")):this.rpc("publish",{runtime:e,expectedRevision:t,sourceRevision:r.revision,state:a})}merge(e,t,r,a){return r.sourceId!==this.projectId?Promise.reject(new Error("Source world mismatch")):this.rpc("merge",{runtime:e,expectedRevision:t,sourceRevision:r.revision,events:a,historyVersion:2})}rename(e){return this.rpc("rename",{name:e})}setProjectVisibility(e){return this.rpc("project-visibility",{visibility:e})}setPermission(e,t){return this.rpc("permission",{participantId:e,permission:t})}revokeAccess(e){return this.rpc("revoke-access",{participantId:e})}pending(){return this.rpc("pending")}preview(e){return this.rpc("preview-read",{participantId:e})}previewWanted(e){return this.rpc("preview-demand",{runtime:e})}publishPreview(e,t,r){return this.rpc("preview-publish",{runtime:e,image:t,geometry:r})}review(e){return this.rpc("review",{id:e})}discard(e){return this.rpc("discard",{id:e})}submission(e,t){if(202===t&&!0===e.pendingApproval&&"string"==typeof e.submissionId)return{status:"pending-approval",submissionId:e.submissionId,threadId:"string"==typeof e.threadId?e.threadId:void 0};if(200===t&&"string"==typeof e.jobId&&"string"==typeof e.threadId&&"number"==typeof e.position)return{...e,status:"queued",jobId:e.jobId,threadId:e.threadId,position:e.position};throw new Error("Unexpected participant submission response")}async send(e,t,r){if(r.sourceId!==this.projectId)throw new Error("Source world mismatch");let a=await this.request("/send",e,{"X-Popmelt-Draft-Revision":String(t),"X-Popmelt-Source-Revision":r.revision});return this.submission(a.data,a.status)}contribute(e,t){return this.rpc("contribute",{threadId:e,text:t})}async approve(e,t){let r=await this.request("/participants/approve",{id:e,revision:t});return this.submission(r.data,r.status)}};async function C(e){let t,n=await k(e.projectRoot,e.directory,e.previousDirectory),p=new Map,c=new Map,l=new Map,d=new Map,u=j(32),h="",m=!1,f=!0,w=0,g=async()=>{let e=w,t=await n.capture();return h=t,e===w&&(f=!1),t};async function y(r){let i=l.get(r.id)||"/";if(r.id===await t){let e=await b();return{basePath:"/",path:i,version:e,basis:e}}let s=await n.findEditable(r.id),o="unversioned"===r.revision?void 0:r.revision;if(!s){let e=await b();if(!o||o===e)return{basePath:"/",path:i,version:e,basis:e}}let d=s||await n.retained(o),u=s?await n.basis(r.id):o,{basePath:h,app:f}=await async function(t,r){if(m)throw new Error("Plane session closed");let i=[...c.entries()].find(([,e])=>e.directory===t)?.[0];i||(i=a+"app/"+j(16).toString("hex")+"/",c.set(i,{directory:t,revision:r}));let s=p.get(t);if(!s){let a=i;s=e.startApp({directory:t,basePath:a,checkoutRoot:n.checkoutRoot(t),sourceRevision:r}).then(async e=>{let t;try{t=new URL(e.origin)}catch(t){throw await e.close(),t}if("http:"!==t.protocol||"127.0.0.1"!==t.hostname||t.origin!==e.origin)throw await e.close(),new Error("Plane app must serve a dedicated loopback origin");return c.get(a).app=e,e}).catch(e=>{throw p.delete(t),c.delete(a),e}),p.set(t,s)}let o=await s;return await(o.ready?.()),{basePath:i,app:o}}(d,u);return{basePath:h,path:i,version:f.version?.()||u,basis:u}}async function v(t,a,i,n,o){let p=t.planeAppBasis;if(!p)throw new Error("Participant plane authorization unavailable");let c,d=a.participantId,u=new O("http://127.0.0.1:"+t.port,t.projectId,a),h=await p(a,i);if(void 0!==n){if(d!==i||"string"!=typeof n||!/^\/(?!\/)/.test(n)||/[?#\\]/.test(n))throw new r(400,"Invalid plane route");let e=s(new URL(n,"http://localhost").pathname);if(e.startsWith("//")||e.startsWith("/__popmelt/"))throw new r(400,"Invalid plane route");c=e,!1!==o&&l.set(d,e)}let m={...await y(h),...e.interactivePage&&{interactivePage:!0}};c&&(m.path=c);let f=void 0===n?await u.read(i):{author:{id:d}};if((await p(a,i)).revision!==h.revision)throw new r(503,"Plane changed during selection");return{...f,application:m}}async function b(){return f||!h?g():h}return{capture:g,hostWorkspace:async()=>({revision:await b(),basePath:"/"}),hostBasis:b,open:v,checkout(t){if("/"===t)return e.projectRoot;let a=c.get(t);if(!a)throw new r(404,"Plane unavailable");return a.directory},async pageReader(e){let t=c.get(e);if(!t)throw new r(404,"Plane unavailable");let a=await p.get(t.directory);return await(a?.ready?.()),a?.pageReader},sourceChanged(){w++,f=!0},async servedAt(e){let t=c.get(i(e));if(!t){let e=await b();return{revision:e,appVersion:e}}let r=(await p.get(t.directory))?.version?.();return{revision:t.revision,appVersion:r??t.revision}},localPreview(e){for(let[t,r]of c)if(r.directory===e&&r.app)return{origin:r.app.origin,basePath:r.app.pageReader?"/":t}},findEditable:n.findEditable,forEdit:async(r,a,i=!1)=>i||r===await t?e.projectRoot:await n.findEditable(r)||n.editable(r,"unversioned"===a?await b():a),middleware(e,n,l){let h=new URL(n);if(!["127.0.0.1","localhost","[::1]"].includes(h.hostname)||h.origin!==n)throw new Error("Participant plane apps require a local app origin");t=e.participantHost?.().then(e=>e.participantId);let f=e.planeAppBasis;if(!f)throw new Error("Plane apps require a local participant bridge.");let w="popmelt-plane-"+P("sha256").update(e.projectId).digest("hex").slice(0,12);return async(t,g,y)=>{let b=t.url??"";if(!b.startsWith(a)){if(!b.startsWith("/")||b.startsWith("//")||b.startsWith("/__popmelt/")||!t.headers.referer||t.headers.host!==h.host||["document","iframe"].includes(String(t.headers["sec-fetch-dest"])))return y();let e;try{e=new URL(t.headers.referer)}catch{return y()}let r=e.origin===n&&i(e.pathname);return r&&c.has(r)?(g.setHeader("Cache-Control","private, no-store"),g.setHeader("Vary","Referer"),"GET"!==t.method&&"HEAD"!==t.method?(g.statusCode=405,void g.end()):(g.writeHead(307,{Location:r.slice(0,-1)+b}),void g.end())):y()}g.setHeader("Cache-Control","private, no-store"),g.setHeader("Referrer-Policy","same-origin"),g.setHeader("Cross-Origin-Resource-Policy","same-origin");let k=e=>{g.destroyed||g.writableEnded||(g.headersSent||(g.statusCode=e),g.end())};if(m||t.headers.host!==h.host||"cross-site"===t.headers["sec-fetch-site"])return k(403);try{if(b===a+"open"){if("POST"!==t.method||t.headers.origin!==n||"application/json"!==t.headers["content-type"])return k(403);let r=t.headers["x-popmelt-participant-id"],i=t.headers["x-popmelt-participant-token"];if("string"!=typeof r||"string"!=typeof i)return k(403);let s,o="";for await(let e of t)if(o+=e,o.length>8192)return k(413);try{s=JSON.parse(o)}catch{return k(400)}let{target:p,pathname:c,active:h}=s??{};if("string"!=typeof p)return k(400);let m={participantId:r,token:i},f=await v(e,m,p,c,h),{application:y}=f,b=I("sha256",u).update(i).digest("hex"),P=Date.now();for(let[e,t]of d)t.expires<=P&&d.delete(e);let j=d.get(b)??{proof:m,mounts:new Map,pages:new Map,expires:0};j.expires=P+36e5;let E=j.mounts.get(y.basePath)??new Set;if(E.add(p),l){let e=j.pages.get(y.basePath)??{routes:new Set,assets:new Set};e.routes.add(y.path),j.pages.set(y.basePath,e)}return j.mounts.set(y.basePath,E),d.set(b,j),g.setHeader("Set-Cookie",w+"="+b+"; Path="+a+"app/; HttpOnly; SameSite=Strict; Max-Age=3600"),g.setHeader("Content-Type","application/json"),void g.end(JSON.stringify(f))}if("GET"!==t.method&&"HEAD"!==t.method)return k(405);let h=new URL(b,n).pathname,m=i(h),y=m&&c.get(m);if("/"===m)return k(404);let P=t.headers.cookie?.split(";").map(e=>e.trim()).find(e=>e.startsWith(w+"="))?.slice(w.length+1),j=P&&d.get(P);if(!y||!j||j.expires<=Date.now()||!j.mounts.has(m)){if("document"===t.headers["sec-fetch-dest"]&&"navigate"===t.headers["sec-fetch-mode"]){let e=s(h);if(!e.startsWith("//")&&!e.startsWith("/__popmelt/"))return g.writeHead(302,{Location:e+new URL(b,n).search}),void g.end()}return k(y?403:404)}let R=j.mounts.get(m);for(let e of R)try{await f(j.proof,e);break}catch(t){if(!(t instanceof r)||404!==t.statusCode)throw t;R.delete(e)}if(!R.size)return k(404);let x=s(h),A=j.pages.get(m)?.routes,H=A?.has(x)?x:o(x),_=A?.has(H),q=["document","iframe"].includes(String(t.headers["sec-fetch-dest"]))||!!t.headers.accept?.includes("text/html")||"HEAD"===t.method&&!0===_,O=await p.get(y.directory);if(!O)return k(503);if(await(O.ready?.()),O.pageReader&&l){let r=new URL(b,n),a=j.pages.get(m);if(!a)return k(403);if(q&&!a.routes.has(H))return k(404);let i=await O.pageReader({url:r,document:q,sharedPath:H,basePath:m,assets:a.assets,projectId:e.projectId,bootstrap:await l(h)});return i?(g.statusCode=i.status,i.headers.forEach((e,t)=>g.setHeader(t,e)),void g.end("HEAD"===t.method?void 0:Buffer.from(await i.arrayBuffer()))):k(404)}let C=E(new URL(b,O.origin),{method:t.method,headers:{accept:t.headers.accept||"*/*"}});C.setTimeout(3e4,()=>C.destroy(new Error("Plane app timed out"))),g.on("close",()=>C.destroy()),C.on("error",()=>k(502)),C.on("response",e=>{g.statusCode=e.statusCode??502;let t=e.headers["content-type"];if(t&&g.setHeader("Content-Type",t),e.headers.location){let t;try{t=new URL(e.headers.location,new URL(b,O.origin))}catch{return e.resume(),k(502)}if(t.origin!==O.origin||!t.pathname.startsWith(m))return e.resume(),k(502);g.setHeader("Location",t.pathname+t.search)}S(e,g).catch(()=>g.destroy())}),C.end()}catch(e){let t=e instanceof r?e.statusCode:e instanceof q?e.status:void 0;k(t&&t>=400&&t<500?t:503)}}},async close(){m=!0,d.clear();let e=(await Promise.allSettled([...p.values()].map(async e=>(await e).close()))).find(e=>"rejected"===e.status);if("rejected"===e?.status)throw e.reason}}}import{execFile as L}from"child_process";import{createHash as M}from"crypto";import{lstat as W,mkdir as D,readFile as U,realpath as T,writeFile as N}from"fs/promises";import{basename as X,dirname as B,join as F,relative as J}from"path";import{promisify as G}from"util";var K=G(L),V={"npm-shrinkwrap.json":"npm","package-lock.json":"npm","pnpm-lock.yaml":"pnpm","yarn.lock":"yarn","bun.lock":"bun","bun.lockb":"bun"},z=[...Object.keys(V),"pnpm-workspace.yaml",".npmrc",".yarnrc.yml",".pnpmfile.cjs","bunfig.toml"],$=["dependencies","devDependencies","optionalDependencies","peerDependencies","peerDependenciesMeta","overrides","resolutions","pnpm","workspaces","packageManager","dependenciesMeta","bundledDependencies","bundleDependencies","engines","os","cpu"];function Y(e){let t=X(e);return"package.json"===t||z.includes(t)}async function Z(e){try{return await e}catch(e){if("ENOENT"!==e.code)throw e}}function Q(e,t){return!t||"object"!=typeof t||Array.isArray(t)?t:Object.fromEntries(Object.entries(t).sort(([e],[t])=>e<t?-1:e>t?1:0))}async function ee(e,t,r){let a,i;for(let r=e;;r=B(r)){let e=await Z(U(F(r,"package.json"),"utf8")),s=await Promise.all([...Object.keys(V),"pnpm-workspace.yaml"].map(e=>Z(W(F(r,e)))));if(e&&(a??=r),s.some(Boolean)||e&&JSON.parse(e).workspaces){i=r;break}if(r===t)break}if(i??=a,!i)return;let s=JSON.parse(await Z(U(F(i,"package.json"),"utf8"))??"{}"),n=M("sha256"),o=M("sha256"),p=await Promise.all(z.map(async e=>[e,await Z(U(F(i,e)))])),c=new Set;for(let[e,t]of p){if(!t)continue;c.add(e);let r=M("sha256").update(t).digest();n.update(e+"\0").update(r),e in V||o.update(e+"\0").update(r)}let l=!!s.workspaces||c.has("pnpm-workspace.yaml"),d=new Set(["package.json",J(i,F(e,"package.json"))]);if(l){let{stdout:e}=await K("git",["ls-files","--cached","--others","--exclude-standard","-z","--",":(glob)**/package.json",":(exclude,glob)**/node_modules/**",":(exclude,glob)**/.popmelt/**"],{cwd:i,maxBuffer:16777216});for(let t of e.split("\0").filter(Boolean))d.add(t)}for(let e of[...d].sort()){let t=await Z(U(F(i,e),"utf8"));if(!t)continue;let r=JSON.parse(t),a=l?[...$,"name","version"]:$,s=Object.fromEntries(a.filter(e=>e in r).map(e=>[e,r[e]]));o.update(e+"\0").update(JSON.stringify(s,Q)+"\0")}let u=new Set(Object.entries(V).filter(([e])=>c.has(e)).map(([,e])=>e));c.has("pnpm-workspace.yaml")&&u.add("pnpm");let h=s.packageManager?.split("@")[0]??(u.size>1?"ambiguous":[...u][0])??"npm",m=o.update(h).digest("hex");return n.update(m),r&&i!==e&&r([...d,...z].map(e=>F(i,e))),{root:i,key:n.digest("hex"),manifestKey:m,manager:h,pnpmWorkspace:c.has("pnpm-workspace.yaml"),manifests:d,present:c}}async function te(e,t,r,a){let i=F(r,J(e,t)),[s,o]=await Promise.all([ee(e,t),ee(r,i,a)]);if(!s)return{installed:!1,graph:"shared"};let p=F(s.root,"node_modules"),c=F(p,".popmelt-install"),l=await Z(U(c,"utf8"));return l===s.key?{installed:!1,graph:"private:"+s.key}:s.key===o?.key&&void 0===l?{installed:!1,graph:"shared:"+s.key}:n(F(t,".popmelt","dependencies.lock"),async()=>{let r=await ee(e,t);if(!r)return{installed:!1,graph:"shared"};let a=F(r.root,"node_modules",".popmelt-install");if(await Z(U(a,"utf8"))===r.key)return{installed:!1,graph:"private:"+r.key};for(let e of[...r.manifests,...r.present]){let t=F(r.root,e),a=await Z(T(t));if(a&&a!==t)throw new Error("Automatic plane installation requires local dependency files: "+e)}await async function(e){for(let t of e.manifests){let r=F(e.root,B(t),"node_modules"),a=await Z(W(r));if(a&&(a.isSymbolicLink()||await T(r)!==r))throw new Error("Plane node_modules points outside its install directory. Use a custom prepare hook.")}let t,r=e.root,a={...process.env,CI:"true",npm_config_global:"false"};switch(e.manager){case"npm":t=["install","--prefix",".","--ignore-scripts","--no-audit","--no-fund","--include=dev"];break;case"pnpm":t=["install","--ignore-scripts","--no-frozen-lockfile","--config.modules-dir=node_modules","--config.virtual-store-dir=node_modules/.pnpm",...e.pnpmWorkspace?[]:["--ignore-workspace"]];break;default:throw new Error("Automatic plane installs require npm or pnpm. Configure participantPlanes.prepare for "+e.manager+".")}await D(F(r,"node_modules"),{recursive:!0}),await N(F(r,"node_modules",".popmelt-install"),"pending"),await K(e.manager,t,{cwd:r,env:a,shell:"win32"===process.platform,timeout:18e4,maxBuffer:4194304})}(r);let i=await ee(e,t);if(!i||r.root!==i.root||r.manifestKey!==i.manifestKey)throw new Error("Plane dependencies changed during installation. Retry with the current manifest.");return await D(F(i.root,"node_modules"),{recursive:!0}),await N(F(i.root,"node_modules",".popmelt-install"),i.key),{installed:!0,graph:"private:"+i.key}},185e3)}export{k as a,C as b,Y as c,te as d};
@@ -0,0 +1 @@
1
+ "use client";import{a as e}from"./chunk-FHCKFQBY.mjs";import{a as t}from"./chunk-APP5IYTE.mjs";import{a as r,b as n}from"./chunk-WP2SHSCG.mjs";import{v as o,l,k as i}from"./chunk-LH7HKUCK.mjs";import{STICKER_FAMILIES as a,stickerDisplayValue as s,stickerSubpropertiesForFamily as f,stickerStepsForFamily as c,stickerProperty as u,stickerValue as p,stickerCompanionStyles as d,stickerBorderStyleProperty as m,normalizeStickerSubproperty as h}from"./sticker-mode.mjs";import{STICKER_COLOR_NAMES as g}from"./sticker-colors.mjs";var y='[role="img"], [role="group"][aria-label], [role="group"][aria-labelledby]';function b(e){let t=e?.closest(y);return t&&"canvas"!==t.localName&&t.querySelector("canvas")?t:null}function w(e,t){let r=t?.querySelector("canvas")?t:b(e);if(!r||r===e)return null;let n=r.querySelectorAll("canvas");if(1!==n.length)return null;let o=n[0].getBoundingClientRect(),l=e.getBoundingClientRect();return o.width<=0||o.height<=0?null:l.left<=o.left+1&&l.top<=o.top+1&&l.right>=o.right-1&&l.bottom>=o.bottom-1?r:null}function S(e){let t=o(e.selector,e.element),a=function(e,t=o(e.selector,e.element)){let n=e.element;if("canvas"!==n?.tagName&&"svg"!==n?.tagName&&!t?.closest("svg,canvas"))return t;let a=b(t);if(a)return a;if(t)return t;let s=n?.selector,f=s?.lastIndexOf(" > ")??-1;if(s&&f>=0)try{let e=b(l(s.slice(0,f)));if(e&&(!n?.reactComponent||r(e)?.name===n.reactComponent))return e}catch{}if(!n?.reactComponent||n.frameContext?.length||s?.includes(" >>> "))return null;let c=i().flatMap(e=>Array.from(e.querySelectorAll(y)).filter(e=>e.querySelector("canvas")&&r(e)?.name===n.reactComponent));return 1===c.length?c[0]:null}(e,t),s=e.element?.reactComponent,f=t&&(s?function(e,t){let r=n(e).findLast(e=>e.name===t)?.fiber;if(!r?.child)return null;let o=[r.child],l=null;for(;o.length;){let e=o.pop();if(4===e.tag)return null;e.sibling&&o.push(e.sibling);let t=e.stateNode;if((1===t?.nodeType||3===t?.nodeType)&&(!l&&1===t.nodeType&&(l=t),!l?.contains(t)))return null;e.child&&o.push(e.child)}return l?.contains(e)?l:null}(t,s):b(t));return{element:t,component:f,legacy:a,legacyScene:t&&w(t,f)}}function E(e,t,r){let n="component"===t?e.component:"element"===t?e.element:r&&e.legacyScene||e.legacy;return n?.isConnected&&n.parentElement&&!n.matches("body,html")&&!n.closest("[data-devtools]")?n:null}var v=["font-family","font-size","font-weight","font-style","font-stretch","font-variation-settings","font-feature-settings","line-height","letter-spacing","white-space","overflow-wrap","word-break","flex-wrap","color"];function x(e){return e.trim().replace(/^(['"])(.*)\1$/,"$2").toLowerCase()}function*N(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,{acceptNode(e){if(e.nodeType===Node.TEXT_NODE)return e.textContent?.trim()?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP;let t=e;return t.matches("script,style,noscript,template,[hidden],[data-devtools],[data-popmelt-root]")?NodeFilter.FILTER_REJECT:t.matches("input,textarea,select")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}}),r=new Set;for(let e=t.nextNode();e;e=t.nextNode()){let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;!t||r.has(t)||(r.add(t),yield[t,e.nodeType===Node.TEXT_NODE?e.textContent.trim():""])}}function C(e){let t=[],r=new Set;for(let[n,o]of N(e)){let l=getComputedStyle(n),i=n.closest("button,a,label"),a=(i&&e.contains(i)?i:n).localName,{fontFamily:s,fontWeight:f,fontSize:c}=l,u=JSON.stringify([a,s,f,c]);if(s&&!r.has(u)&&(r.add(u),t.push({tag:a,text:o.slice(0,64),family:s,weight:f,size:c}),12===t.length))break}return t}function T(e,t){let r=e.ownerDocument,n=[];function o(e){if(!e||e.disabled)return;let t;try{t=e.cssRules}catch{return}l(t,e.href??r.baseURI)}function l(e,r){for(let i of e)if(i.type===CSSRule.FONT_FACE_RULE){let{style:e}=i;if(!t.has(x(e.getPropertyValue("font-family"))))continue;let o=i.cssText.replace(/url\("([^"]*)"\)|url\('([^']*)'\)|url\(([^)]*)\)/gi,(e,t,n,o)=>{try{return"url("+JSON.stringify(new URL(t??n??o.trim(),r).href)+")"}catch{return e}});n.push(o)}else i.type===CSSRule.IMPORT_RULE?o(i.styleSheet):"cssRules"in i&&l(i.cssRules,r)}let i=[r];for(let t=e.getRootNode();"host"in t;t=t.host.getRootNode())i.push(t);for(let e of i)for(let t of[...e.styleSheets,...e.adoptedStyleSheets??[]])o(t);return n}async function k(e,t){let r=function(e,t){let r=new Set([t]);for(let[t]of N(e))t!==e&&r.add(getComputedStyle(t).fontFamily);let n=new Set;for(let e of r)for(let t of e.matchAll(/\s*("[^"]*"|'[^']*'|[^,]+)\s*(?:,|$)/g))n.add(x(t[1]));return n}(e,getComputedStyle(e).fontFamily),n=T(e,r).join("\n"),o=new Set(Array.from(n.matchAll(/url\("([^"]+)"\)/g),e=>e[1])),l=n;return await Promise.all([...o].map(async e=>{if(!e.startsWith("data:"))try{let r=await fetch(e,{signal:t,credentials:"same-origin"});if(!r.ok)return;let n=await r.blob(),o=await new Promise((e,t)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=t,r.readAsDataURL(n)});l=l.replaceAll(JSON.stringify(e),JSON.stringify(o))}catch{}})),l}var I=/^(?:@[a-zA-Z][\w-]{0,63}|~?(?:0|[1-9]\d{0,3})(?:\.(?:0|[1-9]\d{0,3})){0,31}|)$/;function R(e,t){let r="text"===t?e.replace(/\/text\/(?:0|[1-9]\d{0,3})$/,""):e;return I.test(r)}function O(e){if(e.matches('svg, img, [role="img"]'))return!0;if(e.childElementCount||"http://www.w3.org/1999/xhtml"!==e.namespaceURI)return!1;let t=e.ownerDocument.defaultView?.getComputedStyle(e).maskImage;return!!t&&"none"!==t}function A(e){let t=e.getAttribute("data-popmelt-subject-label")||e.getAttribute("data-explore-part");if(t)return t.slice(0,80);let r=e.closest('button, a[href], [role="button"], [role="link"]');if(r===e)return e.matches('a[href], [role="link"]')?"link":"button";let n=e.getAttribute("aria-label");if(O(e)){let t=n||e.getAttribute("alt")||e.querySelector(":scope > title")?.textContent;if(t)return t.slice(0,80);if(r){let t=Array.from(r.querySelectorAll("*")).filter(O);if(t.length>1)return"icon "+(t.indexOf(e)+1)}return"icon"}let o=Array.from(e.childNodes).filter(e=>e.nodeType===Node.TEXT_NODE).map(e=>e.textContent).join(" ").trim();return r&&o?"label":(n||o||e.localName).slice(0,80)}function j(e,t){let r=new Map;for(let n of[...e,...t]){let e=n.part+":"+n.property,t=r.get(e)?.from??n.from;t===n.to?r.delete(e):(r.delete(e),r.set(e,{...n,from:t}))}return[...r.values()]}function F(e){let t=Object.create(null);for(let{batchId:r,option:n,part:o,property:l,to:i}of e){let e=t[r]??(t[r]=Object.create(null)),a=e[n]??(e[n]=Object.create(null));(a[o]??(a[o]=Object.create(null)))[l]=i}return t}function _(e){if(!e||"object"!=typeof e)throw new Error("Invalid Steer edit.");let{batchId:r,option:n,part:o,property:l,from:i,to:s,sticker:f}=e;if("string"!=typeof r||"number"!=typeof n||!Number.isInteger(n)||"string"!=typeof o||"string"!=typeof l||"string"!=typeof i||"string"!=typeof s||("text"===l||"paragraphs"===l)&&void 0!==f)throw new Error("Invalid Steer edit.");"paragraphs"===l?(t(i),t(s)):"text"!==l&&$({[l]:s});let u={batchId:r,option:n,part:o,property:l,from:i,to:s};if(void 0===f)return u;let{family:p,subproperty:d,step:m,axisSteps:g}=f;if(!a.includes(p)||h(p,d)!==d||!c(p,d).includes(m))throw new Error("Invalid Steer dimension.");let y={family:p,subproperty:d,step:m};if(void 0===g)return{...u,sticker:y};let b=c("transform","translate");if("transform"!==p||"translate"!==d||!b.includes(g.x)||!b.includes(g.y))throw new Error("Invalid Steer translation.");return{...u,sticker:{...y,axisSteps:{x:g.x,y:g.y}}}}var L=new Map;function P(e,t){L.has(e)||L.set(e,new Set),L.get(e).add(t)}for(let e of a){let t=s(e);t&&P("display",t);for(let t of f(e))for(let r of"color"===t?g:[t]){let t=c(e,r);for(let n of t){let o=u(e,r);P(o,p(e,n,r));for(let t of d(e,r,n))P(t.property,t.value);if("border"===e&&o.endsWith("width")&&P(m(r),"solid"),"translate"===o)for(let e of t)P(o,4*Number(n)+"px "+4*Number(e)+"px")}}}function U(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Invalid Steer draft.");return Object.entries(e)}function $(e){return Object.fromEntries(U(e).map(([e,t])=>{if("string"!=typeof t||!L.get(e)?.has(t))throw new Error("Unsupported Steer declaration: "+e);return[e,t]}))}function q(e,r){if(void 0===r)return e;let n=structuredClone(e);for(let[e,o]of U(r)){let r=n.messages.find(t=>t.batch?.id===e)?.batch;if(!r)throw new Error("Steer draft refers to an unknown batch.");for(let[e,n]of U(o)){let o=/^[0-5]$/.test(e)&&r.options[Number(e)];if(!o)throw new Error("Steer draft refers to an unknown option.");for(let[e,r]of U(n)){if("fixture"in o){if(!U(r).every(([t])=>R(e,t)))throw new Error("Invalid fixture part.");let{text:n,paragraphs:o,...l}=Object.fromEntries(U(r));if(void 0!==n&&"string"!=typeof n)throw new Error("Invalid fixture text.");if(void 0!==o){if("string"!=typeof o)throw Error("Invalid paragraph draft.");t(o)}$(l);continue}if(!/^(?:[0-7](?:\.[0-7]){0,3})?(?:\/label)?$/.test(e))throw new Error("Invalid specimen path.");let[n,l]=e.split("/"),i=o.root;for(let e of n?n.split("."):[])i=i?.children?.[Number(e)];if(!i||l&&(!i.label||"text"===i.kind))throw new Error("Steered element no longer exists.");let{text:a,...s}=Object.fromEntries(U(r));if(void 0!==a){if("string"!=typeof a||!l&&"text"!==i.kind)throw new Error("Invalid specimen text.");i.label=a}if(Object.keys(s).length){let e=l?"labelStyle":"style";i[e]={...i[e],...$(s)}}}}}return n}function D(e){return[...e.original?.runnable?[e.original.runnable]:[],...e.options]}function W(e,t){if(!e||e.target)return;let r=e.elements?.find(t=>t.selector===e.linkedSelector)??e.elements?.[0],n=e.linkedSelector??r?.selector;return n?{selector:n,element:r,pathname:e.pathname??t}:void 0}var H=new RegExp(`^${e.explore}(?=\\s|$)`,"i");function J(e){let t=H.exec(e.trimStart());return!!t&&!!e.trimStart().slice(t[0].length).trim()}function K(e,t){let r=e.label?.trim().replace(/\s*[→↓]$/,"").slice(0,52),n=r?r[0].toUpperCase()+r.slice(1)+" "+e.kind:e.kind[0].toUpperCase()+e.kind.slice(1),o=e.name||n;return"label"===t?o+" label":o}export{b as a,S as b,E as c,v as d,C as e,k as f,I as g,R as h,A as i,j,F as k,_ as l,q as m,D as n,W as o,J as p,K as q};
@@ -0,0 +1 @@
1
+ import{withThreadWriterLock as r}from"../infra/phone-pairing/writer-lock.mjs";export{r as a};
@@ -0,0 +1 @@
1
+ "use client";import{forwardRef as a}from"react";import{jsxs as h,Fragment as d,jsx as t}from"react/jsx-runtime";function e(d,t){return a(function({size:a=24,width:e=a,height:i=a,color:c="currentColor",className:l,children:r,...p},n){let M=!!r||Object.keys(p).some(a=>a.startsWith("aria-")||"role"===a||"title"===a);return h("svg",{ref:n,xmlns:"http://www.w3.org/2000/svg",width:e,height:i,viewBox:"0 0 24 24",fill:"none",stroke:c,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:l?`lucide ${d} ${l}`:`lucide ${d}`,"aria-hidden":!M||void 0,...p,children:[t,r]})})}var i=e("lucide-wifi",h(d,{children:[t("path",{d:"M2 8.8a16 16 0 0 1 20 0M5 12.9a11 11 0 0 1 14 0M8.5 16.4a5.5 5.5 0 0 1 7 0"}),t("circle",{cx:"12",cy:"20",r:"1",fill:"currentColor",stroke:"none"})]})),c=e("lucide-smartphone",h(d,{children:[t("rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2"}),t("path",{d:"M12 18h.01"})]})),l=e("lucide-a-large-small",h(d,{children:[t("path",{d:"m15 16 2.536-7.328a1.02 1.02 1 0 1 1.928 0L22 16"}),t("path",{d:"M15.697 14h5.606"}),t("path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16"}),t("path",{d:"M3.304 13h6.392"})]})),r=e("lucide-text-align-center lucide-align-center",h(d,{children:[t("path",{d:"M21 5H3"}),t("path",{d:"M17 12H7"}),t("path",{d:"M19 19H5"})]})),p=e("lucide-align-center-vertical",h(d,{children:[t("path",{d:"M12 2v20"}),t("path",{d:"M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4"}),t("path",{d:"M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4"}),t("path",{d:"M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1"}),t("path",{d:"M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1"})]})),n=e("lucide-align-end-vertical",h(d,{children:[t("rect",{width:"16",height:"6",x:"2",y:"4",rx:"2"}),t("rect",{width:"9",height:"6",x:"9",y:"14",rx:"2"}),t("path",{d:"M22 22V2"})]})),M=e("lucide-align-horizontal-justify-center",h(d,{children:[t("rect",{width:"6",height:"14",x:"2",y:"5",rx:"2"}),t("rect",{width:"6",height:"10",x:"16",y:"7",rx:"2"}),t("path",{d:"M12 2v20"})]})),s=e("lucide-align-horizontal-justify-end",h(d,{children:[t("rect",{width:"6",height:"14",x:"2",y:"5",rx:"2"}),t("rect",{width:"6",height:"10",x:"12",y:"7",rx:"2"}),t("path",{d:"M22 2v20"})]})),u=e("lucide-align-horizontal-justify-start",h(d,{children:[t("rect",{width:"6",height:"14",x:"6",y:"5",rx:"2"}),t("rect",{width:"6",height:"10",x:"16",y:"7",rx:"2"}),t("path",{d:"M2 2v20"})]})),o=e("lucide-align-horizontal-space-around",h(d,{children:[t("rect",{width:"6",height:"10",x:"9",y:"7",rx:"2"}),t("path",{d:"M4 22V2"}),t("path",{d:"M20 22V2"})]})),x=e("lucide-align-horizontal-space-between",h(d,{children:[t("rect",{width:"6",height:"14",x:"3",y:"5",rx:"2"}),t("rect",{width:"6",height:"10",x:"15",y:"7",rx:"2"}),t("path",{d:"M3 2v20"}),t("path",{d:"M21 2v20"})]})),v=e("lucide-text-align-justify lucide-align-justify",h(d,{children:[t("path",{d:"M3 5h18"}),t("path",{d:"M3 12h18"}),t("path",{d:"M3 19h18"})]})),g=e("lucide-text-align-start lucide-text lucide-align-left",h(d,{children:[t("path",{d:"M21 5H3"}),t("path",{d:"M15 12H3"}),t("path",{d:"M17 19H3"})]})),m=e("lucide-text-align-end lucide-align-right",h(d,{children:[t("path",{d:"M21 5H3"}),t("path",{d:"M21 12H9"}),t("path",{d:"M21 19H7"})]})),y=e("lucide-align-start-vertical",h(d,{children:[t("rect",{width:"9",height:"6",x:"6",y:"14",rx:"2"}),t("rect",{width:"16",height:"6",x:"6",y:"4",rx:"2"}),t("path",{d:"M2 2v20"})]})),w=e("lucide-archive",h(d,{children:[t("rect",{width:"20",height:"5",x:"2",y:"3",rx:"1"}),t("path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"}),t("path",{d:"M10 12h4"})]})),H=e("lucide-arrow-big-up",t("path",{d:"M9 19a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1v-6a1 1 0 0 1 1-1h3.293a.707.707 0 0 0 .5-1.207l-7.086-7.086a1 1 0 0 0-1.414 0l-7.086 7.086a.707.707 0 0 0 .5 1.207H8a1 1 0 0 1 1 1z"})),z=e("lucide-arrow-down",h(d,{children:[t("path",{d:"M12 5v14"}),t("path",{d:"m19 12-7 7-7-7"})]})),V=e("lucide-arrow-left",h(d,{children:[t("path",{d:"m12 19-7-7 7-7"}),t("path",{d:"M19 12H5"})]})),f=e("lucide-arrow-left-right",h(d,{children:[t("path",{d:"M8 3 4 7l4 4"}),t("path",{d:"M4 7h16"}),t("path",{d:"m16 21 4-4-4-4"}),t("path",{d:"M20 17H4"})]})),L=e("lucide-arrow-right",h(d,{children:[t("path",{d:"M5 12h14"}),t("path",{d:"m12 5 7 7-7 7"})]})),k=e("lucide-arrow-up-right",h(d,{children:[t("path",{d:"M7 7h10v10"}),t("path",{d:"M7 17 17 7"})]})),b=e("lucide-ban",h(d,{children:[t("circle",{cx:"12",cy:"12",r:"10"}),t("path",{d:"M4.929 4.929 19.07 19.071"})]})),A=e("lucide-between-horizontal-start lucide-between-horizonal-start",h(d,{children:[t("rect",{width:"13",height:"7",x:"8",y:"3",rx:"1"}),t("path",{d:"m2 9 3 3-3 3"}),t("rect",{width:"13",height:"7",x:"8",y:"14",rx:"1"})]})),j=e("lucide-between-vertical-end",h(d,{children:[t("rect",{width:"7",height:"13",x:"3",y:"3",rx:"1"}),t("path",{d:"m9 22 3-3 3 3"}),t("rect",{width:"7",height:"13",x:"14",y:"3",rx:"1"})]})),C=e("lucide-blend",h(d,{children:[t("circle",{cx:"15",cy:"9",r:"7"}),t("circle",{cx:"9",cy:"15",r:"7"})]})),q=e("lucide-letter-b lucide-bold",t("path",{d:"M6 12h9a4 4 0 010 8H7a1 1 0 01-1-1V5a1 1 0 011-1h7a4 4 0 010 8"})),N=e("lucide-bot",h(d,{children:[t("path",{d:"M12 8V4H8"}),t("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),t("path",{d:"M2 14h2"}),t("path",{d:"M20 14h2"}),t("path",{d:"M15 13v2"}),t("path",{d:"M9 13v2"})]})),Z=e("lucide-brain",h(d,{children:[t("path",{d:"M12 18V5"}),t("path",{d:"M15 13a4.17 4.17 0 01-3-4 4.17 4.17 0 01-3 4"}),t("path",{d:"M17.707 6.294A3 3 0 1012 5a3 3 0 10-5.707 1.294"}),t("path",{d:"M17.996 5.125a4 4 0 012.526 5.77"}),t("path",{d:"M18 18a4 4 0 002-7.465"}),t("path",{d:"M19.967 17.482a4 4 0 11-7.967.517 4 4 0 11-7.967-.517"}),t("path",{d:"M6 18a4 4 0 01-2-7.465"}),t("path",{d:"M6.004 5.125a4 4 0 00-2.526 5.77"})]})),$=e("lucide-check",t("path",{d:"M20 6 9 17l-5-5"})),B=e("lucide-chevron-down",t("path",{d:"m6 9 6 6 6-6"})),O=e("lucide-chevron-left",t("path",{d:"m15 18-6-6 6-6"})),W=e("lucide-chevron-right",t("path",{d:"m9 18 6-6-6-6"})),D=e("lucide-circle-dashed",h(d,{children:[t("path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0"}),t("path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0"}),t("path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7"}),t("path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8"}),t("path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69"}),t("path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8"}),t("path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69"}),t("path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7"})]})),E=e("lucide-clock",h(d,{children:[t("circle",{cx:"12",cy:"12",r:"10"}),t("path",{d:"M12 6v6l4 2"})]})),F=e("lucide-command",t("path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3"})),G=e("lucide-component",h(d,{children:[t("path",{d:"M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z"}),t("path",{d:"M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z"}),t("path",{d:"M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z"}),t("path",{d:"M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z"})]})),I=e("lucide-copy",h(d,{children:[t("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),t("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})),J=e("lucide-corner-down-left",h(d,{children:[t("path",{d:"M20 4v7a4 4 0 0 1-4 4H4"}),t("path",{d:"m9 10-5 5 5 5"})]})),K=e("lucide-eye",h(d,{children:[t("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),t("circle",{cx:"12",cy:"12",r:"3"})]})),P=e("lucide-fingerprint-pattern lucide-fingerprint",h(d,{children:[t("path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"}),t("path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88"}),t("path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02"}),t("path",{d:"M2 12a10 10 0 0 1 18-6"}),t("path",{d:"M2 16h.01"}),t("path",{d:"M21.8 16c.2-2 .131-5.354 0-6"}),t("path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2"}),t("path",{d:"M8.65 22c.21-.66.45-1.32.57-2"}),t("path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2"})]})),Q=e("lucide-folder",t("path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"})),R=e("lucide-hand",h(d,{children:[t("path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2"}),t("path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2"}),t("path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8"}),t("path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15"})]})),S=e("lucide-rotate-ccw-clock lucide-history",h(d,{children:[t("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),t("path",{d:"M3 3v5h5"}),t("path",{d:"M12 7v5l4 2"})]})),T=e("lucide-image",h(d,{children:[t("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),t("circle",{cx:"9",cy:"9",r:"2"}),t("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})),U=e("lucide-info",h(d,{children:[t("circle",{cx:"12",cy:"12",r:"10"}),t("path",{d:"M12 16v-4"}),t("path",{d:"M12 8h.01"})]})),X=e("lucide-link-2",h(d,{children:[t("path",{d:"M9 17H7A5 5 0 0 1 7 7h2"}),t("path",{d:"M15 7h2a5 5 0 1 1 0 10h-2"}),t("line",{x1:"8",x2:"16",y1:"12",y2:"12"})]})),Y=e("lucide-loader-circle lucide-loader-2",t("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})),_=e("lucide-lock",h(d,{children:[t("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),t("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})),aa=e("lucide-lock-open lucide-unlock",h(d,{children:[t("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),t("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]})),ha=e("lucide-log-out",h(d,{children:[t("path",{d:"m16 17 5-5-5-5"}),t("path",{d:"M21 12H9"}),t("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"})]})),da=e("lucide-maximize-2",h(d,{children:[t("path",{d:"M15 3h6v6"}),t("path",{d:"m21 3-7 7"}),t("path",{d:"m3 21 7-7"}),t("path",{d:"M9 21H3v-6"})]})),ta=e("lucide-message-circle",t("path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"})),ea=e("lucide-message-circle-question-mark lucide-message-circle-question",h(d,{children:[t("path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"}),t("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),t("path",{d:"M12 17h.01"})]})),ia=e("lucide-minimize-2",h(d,{children:[t("path",{d:"m14 10 7-7"}),t("path",{d:"M20 10h-6V4"}),t("path",{d:"m3 21 7-7"}),t("path",{d:"M4 14h6v6"})]})),ca=e("lucide-minus",t("path",{d:"M5 12h14"})),la=e("lucide-monitor",h(d,{children:[t("rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}),t("line",{x1:"8",x2:"16",y1:"21",y2:"21"}),t("line",{x1:"12",x2:"12",y1:"17",y2:"21"})]})),ra=e("lucide-monitor-smartphone",h(d,{children:[t("path",{d:"M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8"}),t("path",{d:"M10 19v-3.96 3.15"}),t("path",{d:"M7 19h5"}),t("rect",{width:"6",height:"10",x:"16",y:"12",rx:"2"})]})),pa=e("lucide-moon",t("path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"})),na=e("lucide-move",h(d,{children:[t("path",{d:"M12 2v20"}),t("path",{d:"m15 19-3 3-3-3"}),t("path",{d:"m19 9 3 3-3 3"}),t("path",{d:"M2 12h20"}),t("path",{d:"m5 9-3 3 3 3"}),t("path",{d:"m9 5 3-3 3 3"})]})),Ma=e("lucide-move-horizontal",h(d,{children:[t("path",{d:"m18 8 4 4-4 4"}),t("path",{d:"M2 12h20"}),t("path",{d:"m6 8-4 4 4 4"})]})),sa=e("lucide-move-vertical",h(d,{children:[t("path",{d:"M12 2v20"}),t("path",{d:"m8 18 4 4 4-4"}),t("path",{d:"m8 6 4-4 4 4"})]})),ua=e("lucide-octagon-alert lucide-alert-octagon",h(d,{children:[t("path",{d:"M12 16h.01"}),t("path",{d:"M12 8v4"}),t("path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z"})]})),oa=e("lucide-palette",h(d,{children:[t("path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z"}),t("circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor"}),t("circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor"}),t("circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor"}),t("circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor"})]})),xa=e("lucide-pause",h(d,{children:[t("rect",{x:"14",y:"3",width:"5",height:"18",rx:"1"}),t("rect",{x:"5",y:"3",width:"5",height:"18",rx:"1"})]})),va=e("lucide-pen-line lucide-edit-3",h(d,{children:[t("path",{d:"M13 21h8"}),t("path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"})]})),ga=e("lucide-play",t("path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"})),ma=e("lucide-plug",h(d,{children:[t("path",{d:"M12 22v-5"}),t("path",{d:"M15 8V2"}),t("path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z"}),t("path",{d:"M9 8V2"})]})),ya=e("lucide-plus",h(d,{children:[t("path",{d:"M5 12h14"}),t("path",{d:"M12 5v14"})]})),wa=e("lucide-refresh-cw",h(d,{children:[t("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),t("path",{d:"M21 3v5h-5"}),t("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),t("path",{d:"M8 16H3v5"})]})),Ha=e("lucide-reply",h(d,{children:[t("path",{d:"M20 18v-2a4 4 0 0 0-4-4H4"}),t("path",{d:"m9 17-5-5 5-5"})]})),za=e("lucide-rotate-ccw",h(d,{children:[t("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),t("path",{d:"M3 3v5h5"})]})),Va=e("lucide-rotate-cw",h(d,{children:[t("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),t("path",{d:"M21 3v5h-5"})]})),fa=e("lucide-ruler",h(d,{children:[t("path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z"}),t("path",{d:"m14.5 12.5 2-2"}),t("path",{d:"m11.5 9.5 2-2"}),t("path",{d:"m8.5 6.5 2-2"}),t("path",{d:"m17.5 15.5 2-2"})]})),La=e("lucide-scaling",h(d,{children:[t("path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t("path",{d:"M14 15H9v-5"}),t("path",{d:"M16 3h5v5"}),t("path",{d:"M21 3 9 15"})]})),ka=e("lucide-search",h(d,{children:[t("path",{d:"m21 21-4.34-4.34"}),t("circle",{cx:"11",cy:"11",r:"8"})]})),ba=e("lucide-send",h(d,{children:[t("path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z"}),t("path",{d:"m21.854 2.147-10.94 10.939"})]})),Aa=e("lucide-send-horizontal lucide-send-horizonal",h(d,{children:[t("path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z"}),t("path",{d:"M6 12h16"})]})),ja=e("lucide-settings",h(d,{children:[t("path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}),t("circle",{cx:"12",cy:"12",r:"3"})]})),Ca=e("lucide-signal",h(d,{children:[t("path",{d:"M2 20h.01"}),t("path",{d:"M7 20v-4"}),t("path",{d:"M12 20v-8"}),t("path",{d:"M17 20V8"}),t("path",{d:"M22 4v16"})]})),qa=e("lucide-signal-high",h(d,{children:[t("path",{d:"M2 20h.01"}),t("path",{d:"M7 20v-4"}),t("path",{d:"M12 20v-8"}),t("path",{d:"M17 20V8"})]})),Na=e("lucide-signal-low",h(d,{children:[t("path",{d:"M2 20h.01"}),t("path",{d:"M7 20v-4"})]})),Za=e("lucide-signal-medium",h(d,{children:[t("path",{d:"M2 20h.01"}),t("path",{d:"M7 20v-4"}),t("path",{d:"M12 20v-8"})]})),$a=e("lucide-signal-zero",t("path",{d:"M2 20h.01"})),Ba=e("lucide-sliders-horizontal",h(d,{children:[t("path",{d:"M10 5H3"}),t("path",{d:"M12 19H3"}),t("path",{d:"M14 3v4"}),t("path",{d:"M16 17v4"}),t("path",{d:"M21 12h-9"}),t("path",{d:"M21 19h-5"}),t("path",{d:"M21 5h-7"}),t("path",{d:"M8 10v4"}),t("path",{d:"M8 12H3"})]})),Oa=e("lucide-mouse-pointer-2",t("path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z"})),Wa=e("lucide-square-mouse-pointer lucide-inspect",h(d,{children:[t("path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"}),t("path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6"})]})),Da=e("lucide-stretch-horizontal",h(d,{children:[t("rect",{width:"20",height:"6",x:"2",y:"4",rx:"2"}),t("rect",{width:"20",height:"6",x:"2",y:"14",rx:"2"})]})),Ea=e("lucide-sun",h(d,{children:[t("circle",{cx:"12",cy:"12",r:"4"}),t("path",{d:"M12 2v2"}),t("path",{d:"M12 20v2"}),t("path",{d:"m4.93 4.93 1.41 1.41"}),t("path",{d:"m17.66 17.66 1.41 1.41"}),t("path",{d:"M2 12h2"}),t("path",{d:"M20 12h2"}),t("path",{d:"m6.34 17.66-1.41 1.41"}),t("path",{d:"m19.07 4.93-1.41 1.41"})]})),Fa=e("lucide-terminal",h(d,{children:[t("path",{d:"M12 19h8"}),t("path",{d:"m4 17 6-6-6-6"})]})),Ga=e("lucide-thumbs-up",h(d,{children:[t("path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"}),t("path",{d:"M7 10v12"})]})),Ia=e("lucide-trash lucide-trash-2",h(d,{children:[t("path",{d:"M10 11v6"}),t("path",{d:"M14 11v6"}),t("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}),t("path",{d:"M3 6h18"}),t("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})),Ja=e("lucide-triangle-alert lucide-alert-triangle",h(d,{children:[t("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),t("path",{d:"M12 9v4"}),t("path",{d:"M12 17h.01"})]})),Ka=e("lucide-user",h(d,{children:[t("path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}),t("circle",{cx:"12",cy:"7",r:"4"})]})),Pa=e("lucide-user-plus",h(d,{children:[t("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),t("circle",{cx:"9",cy:"7",r:"4"}),t("line",{x1:"19",x2:"19",y1:"8",y2:"14"}),t("line",{x1:"22",x2:"16",y1:"11",y2:"11"})]})),Qa=e("lucide-x",h(d,{children:[t("path",{d:"M18 6 6 18"}),t("path",{d:"m6 6 12 12"})]})),Ra=e("lucide-zap",t("path",{d:"M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z"}));export{ta as $,C as A,Ca as Aa,q as B,qa as Ba,N as C,Na as Ca,Z as D,Za as Da,$ as E,$a as Ea,B as F,Ba as Fa,O as G,Oa as Ga,W as H,Wa as Ha,D as I,Da as Ia,E as J,Ea as Ja,F as K,Fa as Ka,G as L,Ga as La,I as M,Ia as Ma,J as N,Ja as Na,K as O,Ka as Oa,P,Pa,Q,Qa,R,Ra,S,T,U,X as V,Y as W,_ as X,aa as Y,ha as Z,da as _,e as a,ea as aa,i as b,ia as ba,c,ca,l as d,la as da,r as e,ra as ea,p as f,pa as fa,n as g,na as ga,M as h,Ma as ha,s as i,sa as ia,u as j,ua as ja,o as k,oa as ka,x as l,xa as la,v as m,va as ma,g as n,ga as na,m as o,ma as oa,y as p,ya as pa,w as q,wa as qa,H as r,Ha as ra,z as s,za as sa,V as t,Va as ta,f as u,fa as ua,L as v,La as va,k as w,ka as wa,b as x,ba as xa,A as y,Aa as ya,j as z,ja as za};
@@ -0,0 +1 @@
1
+ var t="~popmelt-frame.html",e="~popmelt-runtime.html";function r(r){for(let l of[t,e])if(r.endsWith(l))return r.slice(0,-l.length);return r}export{t as a,e as b,r as c};
@@ -1 +1 @@
1
- "use client";import{b as e}from"./chunk-QYNW5LE2.mjs";import{b as t,f as r,g as n,j as i,h as o,l as a,c as l,a as s,d as c,q as p}from"./chunk-AWWUJO3N.mjs";import{c as d,b as u}from"./chunk-Q6N77LIS.mjs";import{o as h,m,a as f}from"./chunk-AOTDTBQO.mjs";import{v as g,m as y}from"./chunk-LH7HKUCK.mjs";import{c as b}from"./chunk-ZVDKW7TO.mjs";import{a as v}from"./chunk-7D4BUDKG.mjs";import{b as w}from"./chunk-OEJXPUAR.mjs";import{createContext as x,useState as k,useRef as S,useLayoutEffect as C,useContext as E,useMemo as O}from"react";import{createPortal as W}from"react-dom";import{jsx as T,Fragment as M,jsxs as P}from"react/jsx-runtime";var j=x({visible:!0,toggle:()=>{}});function A(e,t,r){let n=e.closest(".sp-card");if(!n)return;let i=e.closest(".sp-steer-frame")??e,o=Array.from(n.querySelectorAll(".sp-zoom-actions, .sp-actions, .tag-option, .pager")),a=()=>{let r=e.getBoundingClientRect();if(!r.width||!r.height)return;let a=e.clientWidth/r.width,l=e.clientHeight/r.height;t({compact:!n.closest(".sp-workspace"),viewport:{width:i.clientWidth,height:i.clientHeight},bounds:o.map(e=>{let t=e.getBoundingClientRect();return{left:(t.left-r.left)*a,right:(t.right-r.left)*a,top:(t.top-r.top)*l,bottom:(t.bottom-r.top)*l}})})},l=new ResizeObserver(a);l.observe(i),l.observe(n);for(let e of o)l.observe(e),e.addEventListener("pointermove",r,{passive:!0});return a(),()=>{l.disconnect();for(let e of o)e.removeEventListener("pointermove",r)}}function R(e,t){return e.computedStyleMap?.().get(t)?.toString()??("max-width"===t?getComputedStyle(e).maxWidth:f(e,t))}function I(e){let t=getComputedStyle(e).display,r=R(e,"width");return"inline"===t||t.startsWith("inline-")&&(!r||"auto"===r)||/^(fit-content|max-content|min-content)/.test(r??"")}function F(e,t){let r=h(e)??e,n=I(r);if(!n){let e=r instanceof HTMLElement?r.offsetWidth:r.getBoundingClientRect().width;if(e>0)return{width:e,intrinsic:n}}for(let e=y(r);e;e=y(e)){if(!e.clientWidth||I(e))continue;let r=getComputedStyle(e),n=e.clientWidth-(parseFloat(r.paddingLeft)||0)-(parseFloat(r.paddingRight)||0);n>0&&(t=Math.min(t,n));break}return{width:t,intrinsic:n}}function N(e,t){if(e){if(/^[\d.]+px$/.test(e))return parseFloat(e);if(/^[\d.]+%$/.test(e))return t*parseFloat(e)/100}}function z(e){let t=[];for(let r=e;r;r=y(r))t.unshift(r);return{boxes:t,measure:function(r=!1){let n=e.ownerDocument.documentElement.clientWidth;for(let i of t){let t=getComputedStyle(i);if("inline"===t.display||"contents"===t.display)continue;let o=(parseFloat(t.paddingLeft)||0)+(parseFloat(t.paddingRight)||0)+(parseFloat(t.borderLeftWidth)||0)+(parseFloat(t.borderRightWidth)||0),a="border-box"===t.boxSizing,l=N(R(i,"width"),n),s=N(R(i,"max-width"),n),c=void 0===l?n-o:l-(a?o:0);n=Math.max(0,Math.min(c,void 0===s?1/0:s-(a?o:0))),r&&i===e&&(n+=o)}return n}}}function L(e,t,r){let n={},i=e&&getComputedStyle(e);if(i)for(let e of c)n[e]=i.getPropertyValue(e);let o=d(),a=e=>{let{raisedSurface:t,primary:r}=v[e];return i&&o&&u(o(i.color,t),o(t,t))>=4.5?i.color:r};return{style:n,width:t,fonts:r,lightInk:a("light"),darkInk:a("dark")}}function D(e,t){let r=t.flatMap(e=>"fixture"in e?[e.fixture.bundle]:[]).join(","),[n,i]=k({}),o=S(new Map);return C(()=>{let e=o.current;return i({}),()=>{for(let t of e.values())t.abort();e.clear()}},[e]),C(()=>{let t=o.current;for(let n of r.split(",")){if(!/^[a-f0-9]{64}$/.test(n)||t.has(n))continue;let r=new AbortController;t.set(n,r),w(e+"/files/explore-"+n+".json",{signal:r.signal}).then(async e=>{if(409===e.status)return"The saved recipe could not reproduce the original preview with this checkout.";if(!e.ok)throw Error("This fixture bundle could not be loaded.");let t=await e.json();if("string"!=typeof t.script||"string"!=typeof t.css)throw Error("Invalid fixture bundle.");return t}).catch(()=>"This fixture bundle could not be loaded.").then(e=>{r.signal.aborted||i(t=>({...t,[n]:e}))})}},[e,r]),n}function B({frameKey:e,bundle:t,...r}){let[n,i]=k(null);if("string"==typeof t)return T("div",{className:"sp-steer-frame",role:"alert",children:t});let o=n&&n.key!==e?n:null,a=[];return o&&a.push(T(K,{...o.props,captureRef:void 0,presentation:"retiring"},o.key)),t&&a.push(T(K,{...r,bundle:t,presentation:n?.key===e?"current":"pending",onReady:()=>i({key:e,props:{...r,bundle:t}})},e)),a.length?T(M,{children:a}):T("div",{className:"sp-steer-frame",role:"status",children:"Loading preview…"})}function K(l){let s=b(),c=S(null),p=S(null),d=S(null),u=S(null),h=S(null),m=S({...l,feedbackOnly:s});m.current={...l,feedbackOnly:s};let{toggle:f}=E(j),y=S(f);y.current=f;let[v,w]=k(0),[x,W]=k(""),R=O(()=>{if(l.readOnly&&!l.frozenParent||location.pathname!==l.target.pathname)return null;if("component"===l.previewScope){let{component:e,element:r}=t(l.target);return e??r}return g(l.target.selector,l.target.element)},[l.target,l.previewScope,l.readOnly,l.frozenParent]),{mirror:I,fillScene:N,framing:D,capture:B,readOnly:K}=l,H=O(()=>({script:l.bundle.script,css:l.bundle.css}),[l.bundle.script,l.bundle.css]);C(()=>{c.current&&(c.current.inert="retiring"===l.presentation||"pending"===l.presentation)},[l.presentation]),C(()=>{let e=c.current;if(!v||!e?.contentWindow)return;let{port1:t,port2:l}=new MessageChannel;u.current=t;let s,f=m.current.initial,g=R&&z(R),b="",w=()=>{let e=L(R,g?.measure()??document.documentElement.clientWidth,b);if(B&&(e.width=B.width,e.style=B.style,e.lightInk=e.darkInk=B.style.color||"currentColor"),m.current.pageInk&&(e.lightInk=e.darkInk=m.current.pageInk),p.current){let t=s??{width:p.current.clientWidth,height:p.current.clientHeight};if(I){let r=R&&!N?F(R,g?.measure(!0)??e.width):null;e.slot=r?{width:r.width,height:t.height}:t,r&&(e.intrinsic=r.intrinsic)}else e.surface=B?{width:Math.min(B.viewport.width,t.width),height:Math.min(B.viewport.height,t.height)}:t,R&&Object.assign(e,F(R,e.width))}return e},x=!1,k=e=>{(x||!I)&&t.postMessage(e)},S=()=>k({type:"reference",reference:w(),theme:m.current.theme});h.current=S;let C=new ResizeObserver(e=>{let t=e.find(e=>e.target===p.current)?.contentRect;t&&(s={width:t.width,height:t.height}),S()});for(let e of g?.boxes??[])C.observe(e);p.current&&C.observe(p.current),C.observe(e.ownerDocument.documentElement);let E=!1,O=new AbortController,T=R?r(R,O.signal).then(e=>{!E&&e&&(b=e,S())}).catch(()=>{}):Promise.resolve(),M=I?void 0:A(e,e=>k({type:"controls",bounds:e}),()=>k({type:"controlEnter"})),P=e.closest(".sp-workspace"),j=["wheel","gesturestart","gesturechange","gestureend"],X=t=>{if(!D||"retiring"===m.current.presentation)return;let r=t;if("wheel"===r.type&&!r.ctrlKey&&1===D.getScale())return;t.preventDefault(),t.stopPropagation();let n=e.getBoundingClientRect();k({type:"framingGesture",event:r.type,clientX:r.clientX-n.left,clientY:r.clientY-n.top,deltaX:r.deltaX,deltaY:r.deltaY,deltaMode:r.deltaMode,ctrlKey:r.ctrlKey,scale:r.scale??1})};for(let e of j)P?.addEventListener(e,X,{capture:!0,passive:!1});let Y=JSON.stringify(f),U=!1,V=D?.subscribe(()=>{U||k({type:"framing",view:D.snapshot()})}),$=0,J=!1,q=new Map,Q=()=>new Promise((e,t)=>{if(!J||E)return void t(Error("The option is still loading. Try again in a moment."));let r=++$,n=setTimeout(()=>{q.delete(r),t(Error("The preview capture timed out. Please try again."))},8e3);q.set(r,{resolve:e,reject:t,timer:n}),k({type:"capture",id:r,background:m.current.captureBackground??"transparent"})}),G=m.current.captureRef;G&&(G.current=Q),t.onmessage=({data:e})=>{if(!E&&"retiring"!==m.current.presentation&&e&&"object"==typeof e)switch(e.type){case"capture":{let t=q.get(e.id);if(!t)break;q.delete(e.id),clearTimeout(t.timer),e.image instanceof Blob&&"image/png"===e.image.type&&e.image.size>0&&e.image.size<=8388608?t.resolve(e.image):t.reject(Error("Could not capture the reviewed option. Please try again."));break}case"edits":if(I||!Array.isArray(e.edits)||e.edits.length>512)return;try{let t=i(f,e.edits.map(e=>{if(!o(e.part,e.property))throw Error();return a({...e,batchId:"",option:0}),e})),r=JSON.stringify(t);Y!==r&&(Y=r,m.current.onChange?.(t))}catch{}break;case"framing":{let{view:t,fit:r}=e;if(!D||!Number.isFinite(r)||r<=0||r>1||!t||!(null===t.pageScale||Number.isFinite(t.pageScale)&&t.pageScale>0&&t.pageScale<=4)||!Number.isFinite(t.focusX)||!Number.isFinite(t.focusY))return;U=!0,D.setFitScale(r),D.restore(t),U=!1;break}case"tag":!I&&"string"==typeof e.part&&n.test(e.part)&&m.current.onTag?.(e.part,"string"==typeof e.label?e.label.slice(0,80):void 0);break;case"preview":m.current.onPreview?.(e.parts);break;case"escape":m.current.onEscape?.();break;case"toggle":I||y.current();break;case"canvas":"boolean"==typeof e.present&&m.current.onCanvas?.(e.present);break;case"ready":J=!0,m.current.onReady?.(),k({type:"interaction",selected:m.current.selected,feedbackOnly:m.current.feedbackOnly}),I&&k({type:"styles",parts:m.current.parts??{}});break;case"size":d.current&&Number.isFinite(e.width)&&Number.isFinite(e.height)&&(d.current.style.height=Math.min(16384,Math.max(1,e.height))+"px",d.current.style.width=Math.min(16384,Math.max(1,e.width))+"px");break;case"error":m.current.onError?.(),I||m.current.onReady?.(),W(String(e.message).slice(0,300))}};let Z=()=>{E||!e.contentWindow||(x=!0,e.contentWindow.postMessage({bundle:H,initial:f,parts:I?m.current.parts:void 0,reference:w(),theme:m.current.theme,accent:m.current.accent,framing:D?.snapshot()??{pageScale:null,focusX:0,focusY:0},feedbackOnly:m.current.feedbackOnly,readOnly:K,mirror:!!I,fillScene:N},"*",[l]))};return I?T.then(Z):Z(),()=>{for(let e of j)P?.removeEventListener(e,X,!0);E=!0,M?.(),C.disconnect(),O.abort(),V?.(),u.current=null,h.current=null,t.close(),G?.current===Q&&(G.current=null);for(let e of q.values())clearTimeout(e.timer),e.reject(Error("The preview changed before it could be captured. Try again."));q.clear(),m.current.onPreview?.(null)}},[v,H,R,I,N,D,B,K]),C(()=>{u.current?.postMessage({type:"interaction",selected:l.selected,feedbackOnly:s})},[l.selected,s]),C(()=>{u.current?.postMessage({type:"styles",parts:l.parts??{}})},[l.parts]),C(()=>{h.current?.()},[l.theme,l.pageInk]);let X=T("iframe",{ref:c,title:l.frozenParent?"Edited parent at iteration time":K?"Original at exploration time":I?"Explore page preview":"Edit or interact with this option",sandbox:"allow-scripts","aria-hidden":"retiring"===l.presentation||void 0,referrerPolicy:"no-referrer",srcDoc:e,style:{border:0,colorScheme:I?void 0:l.theme,display:"block",position:"absolute",top:B?"max(0px, calc(50% - "+B.viewport.height/2+"px))":0,left:B?"max(0px, calc(50% - "+B.viewport.width/2+"px))":0,width:B?.viewport.width??"100vw",height:B?.viewport.height??"100vh",maxWidth:"none",maxHeight:"none",opacity:"pending"===l.presentation?0:1},onLoad:()=>w(e=>e+1)});return P(M,{children:[P("span",{ref:p,className:I?void 0:"sp-steer-frame",style:{display:"block",overflow:"clip",...I?{position:"relative",minWidth:0,height:N?"100%":void 0}:{gridArea:"1 / 1"}},children:[I&&!N&&T("span",{ref:d,"aria-hidden":"true",style:{display:"block",maxWidth:"100%"}}),X]}),x&&T("span",{role:"alert",children:x})]})}function H(e){return Object.fromEntries(Object.entries(e??{}).map(([e,t])=>[e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase()),t]))}function X({node:e,picker:t,path:r=[],live:n}){let i="row"===e.kind||"column"===e.kind,o=r.join("."),a={display:"inline-flex",flexDirection:"column"===e.kind?"column":"row",alignItems:i&&"column"===e.kind?"flex-start":"center",gap:e.space??0,flexWrap:i&&"row"===e.kind?"inherit":void 0,maxWidth:"100%",boxSizing:"border-box",color:e.ink,background:e.fill,border:e.stroke?"1px solid "+e.stroke:void 0,borderRadius:e.radius,padding:e.px||e.py?String(e.py??0)+"px "+String(e.px??0)+"px":void 0,fontSize:e.size?e.size+"px":void 0,fontWeight:e.weight,...H(e.style),...H(n?.[o])},l=o+"/label",s=!i&&"text"!==e.kind;return P("span",{style:a,className:[t&&"sp-piece"].filter(Boolean).join(" ")||void 0,"data-sp-fill":t&&(e.fill||a.backgroundColor)?"":void 0,"data-sp-ink":t&&a.color?"":void 0,"data-scratch-text":"text"===e.kind||void 0,"data-popmelt-label":p(e),"data-scratch-part":o,tabIndex:t?-1:void 0,"data-badge-hover":t?.hovered===o||void 0,"data-tagged":t?.selected===o||void 0,children:[t&&T("button",{type:"button",className:"sp-piece-hit",onClick:()=>t.tag(o),"aria-label":`Tag ${e.kind}${e.label?": "+e.label:""}`,"aria-pressed":t.selected===o}),i?e.children?.map((e,i)=>T(X,{live:n,node:e,path:[...r,i],picker:t},i)):t&&s?T("button",{type:"button",className:"sp-label-hit","data-popmelt-label":p(e,"label"),"data-sp-fill":e.labelStyle?.["background-color"]?"":void 0,"data-sp-ink":e.labelStyle?.color?"":void 0,"data-scratch-text":"",style:H(e.labelStyle),"data-scratch-part":l,"data-badge-hover":t.hovered===l||void 0,"data-tagged":t.selected===l||void 0,onClick:()=>t.tag(l),"aria-label":"Tag text: "+e.label,"aria-pressed":t.selected===l,children:n?.[l]?.text??e.label}):s?T("span",{"data-popmelt-label":p(e,"label"),"data-scratch-part":l,style:{display:"inline-block",...H(e.labelStyle),...H(n?.[l])},children:n?.[l]?.text??e.label}):n?.[o]?.text??e.label]})}function Y({element:e,scene:t,active:r,revealOnPage:n,children:i}){let[o,a]=k(null);return C(()=>{let r=e.ownerDocument,n=r.createElement("span");n.dataset.popmeltExploreCache="",n.setAttribute("inert","");let i=!t&&(e.hasAttribute("data-popmelt-explore-original")?h(e)??e:e),o=getComputedStyle(i||e);if(t)n.style.cssText="position:absolute;inset:0;display:block;overflow:hidden";else{if(n.style.display=o.display.startsWith("inline")?"inline-flex":"block","absolute"===o.position||"fixed"===o.position)for(let e of["position","top","right","bottom","left","z-index","transform","transform-origin"])n.style.setProperty(e,o.getPropertyValue(e));if("inline"!==o.display)for(let t of["width","max-width"]){let r=R(i||e,t);r&&n.style.setProperty(t,r)}for(let e of[...c,"align-self","grid-area","margin"])n.style.setProperty(e,o.getPropertyValue(e))}let l=n.style.cssText;n.style.visibility="hidden",t||(n.style.position="fixed",n.style.left="0",n.style.top="0",n.style.width=z(e).measure()+"px",n.style.height="0",n.style.overflow="clip");let s=r.createElement("style");return s.textContent="[data-popmelt-explore-original] { display: none !important; } [data-popmelt-explore-scene] > :not([data-popmelt-explore-preview]) { opacity: 0 !important; pointer-events: none !important; } [data-popmelt-explore-scene-position] { position: relative !important; }",t?(n.append(s),e.append(n)):e.before(s,n),a({host:n,style:l,position:"static"===o.position||e.hasAttribute("data-popmelt-explore-scene-position")}),()=>{n.remove(),s.remove()}},[e,t]),C(()=>{if(!o||!r)return;let{host:n,style:i,position:a}=o,l=n.style.cssText;n.style.cssText=i,n.dataset.popmeltExplorePreview="";let s=t?"data-popmelt-explore-scene":"data-popmelt-explore-original";t&&a&&e.setAttribute("data-popmelt-explore-scene-position",""),e.setAttribute(s,"");let c=m(e,n);return()=>{e.removeAttribute(s),t&&a&&e.removeAttribute("data-popmelt-explore-scene-position"),n.removeAttribute("data-popmelt-explore-preview"),n.style.cssText=l,c()}},[o,e,t,r]),C(()=>{if(!o||!r||!n)return;let e=requestAnimationFrame(()=>o.host.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"}));return()=>cancelAnimationFrame(e)},[o,r,n]),o&&W(i,o.host)}function U({preview:e,active:r,onReady:n}){let{option:i,target:o,bundle:a,parts:c,theme:p,accentColor:d,hasCanvas:u,revealOnPage:h}=e,[m,f]=k(e.targets),[g,y]=k(null);C(()=>f(e.targets),[e.targets]);let b="fixture"in i?l(m,i.previewScope,u):m.element;if(C(()=>{let e=()=>{if(b?.isConnected)return;let e=t(o);(e.element!==m.element||e.component!==m.component||e.legacyScene!==m.legacyScene)&&f(e)},r=new MutationObserver(e);return r.observe(document,{subtree:!0,childList:!0}),e(),()=>r.disconnect()},[b,o,m]),C(()=>{!("fixture"in i)&&b?.isConnected&&n()},[i,b,n]),!b?.isConnected)return null;let v="fixture"in i&&(s(b)===b||(b===m.component||b===m.legacyScene)&&!!b.querySelector("canvas"));return T(Y,{element:b,scene:v,active:r&&(!("fixture"in i)||g?.element===b&&g.scene===v),revealOnPage:h,children:"fixture"in i?a&&T(K,{mirror:!0,fillScene:v,bundle:a,target:o,previewScope:i.previewScope,theme:p,accent:d,initial:[],parts:c,onReady:()=>{y({element:b,scene:v}),n()}}):T(X,{node:i.root,live:c})})}function V({preview:e}){let t=e.index>=0?(e=>e.threadId+":"+e.batchId+":"+e.index+("fixture"in e.option?":"+e.option.fixture.bundle:""))(e):null,[r,n]=k([]),[i,o]=k(null),a=r.find(e=>e.key===t),l=e.enabled&&!e.suspended&&null!==t?a?.ready?t:i:null;return C(()=>{l!==i&&o(l)},[l,i]),C(()=>{!t||"fixture"in e.option&&!e.bundle||n(r=>{let n=r.find(e=>e.key===t),o=r.filter(e=>e.key!==t);for(;o.length>2;){let e=o.findIndex(e=>e.key!==i);o.splice(e,1)}return[...o,{key:t,preview:e,ready:n?.ready??!1}]})},[t,e,i]),T(M,{children:r.map(r=>T(U,{preview:r.key===t?e:r.preview,active:e.enabled&&!e.suspended&&null!==t&&r.key===l,onReady:()=>n(e=>e.some(e=>e.key===r.key&&!e.ready)?e.map(e=>e.key===r.key?{...e,ready:!0}:e):e)},r.key))})}export{j as a,A as b,D as c,B as d,K as e,V as f};
1
+ "use client";import{b as e}from"./chunk-GLIGPLM4.mjs";import{b as t,f as r,g as n,j as i,h as o,l as a,c as l,a as s,d as c,q as p}from"./chunk-JWWWU4GY.mjs";import{c as d,b as u}from"./chunk-Q6N77LIS.mjs";import{o as h,m,a as f}from"./chunk-AOTDTBQO.mjs";import{v as g,m as y}from"./chunk-LH7HKUCK.mjs";import{c as b}from"./chunk-ZVDKW7TO.mjs";import{a as v}from"./chunk-7D4BUDKG.mjs";import{b as w}from"./chunk-OEJXPUAR.mjs";import{createContext as x,useState as k,useRef as S,useLayoutEffect as C,useContext as E,useMemo as O}from"react";import{createPortal as W}from"react-dom";import{jsx as M,Fragment as P,jsxs as T}from"react/jsx-runtime";var j=x({visible:!0,toggle:()=>{}});function R(e,t,r){let n=e.closest(".sp-card");if(!n)return;let i=e.closest(".sp-steer-frame")??e,o=Array.from(n.querySelectorAll(".sp-zoom-actions, .sp-actions, .tag-option, .pager")),a=()=>{let r=e.getBoundingClientRect();if(!r.width||!r.height)return;let a=e.clientWidth/r.width,l=e.clientHeight/r.height;t({compact:!n.closest(".sp-workspace"),viewport:{width:i.clientWidth,height:i.clientHeight},bounds:o.map(e=>{let t=e.getBoundingClientRect();return{left:(t.left-r.left)*a,right:(t.right-r.left)*a,top:(t.top-r.top)*l,bottom:(t.bottom-r.top)*l}})})},l=new ResizeObserver(a);l.observe(i),l.observe(n);for(let e of o)l.observe(e),e.addEventListener("pointermove",r,{passive:!0});return a(),()=>{l.disconnect();for(let e of o)e.removeEventListener("pointermove",r)}}function A(e,t){return e.computedStyleMap?.().get(t)?.toString()??("max-width"===t?getComputedStyle(e).maxWidth:f(e,t))}function I(e){let t=getComputedStyle(e).display,r=A(e,"width");return"inline"===t||t.startsWith("inline-")&&(!r||"auto"===r)||/^(fit-content|max-content|min-content)/.test(r??"")}function F(e,t){let r=h(e)??e,n=I(r);if(!n){let e=r instanceof HTMLElement?r.offsetWidth:r.getBoundingClientRect().width;if(e>0)return{width:e,intrinsic:n}}for(let e=y(r);e;e=y(e)){if(!e.clientWidth||I(e))continue;let r=getComputedStyle(e),n=e.clientWidth-(parseFloat(r.paddingLeft)||0)-(parseFloat(r.paddingRight)||0);n>0&&(t=Math.min(t,n));break}return{width:t,intrinsic:n}}function z(e,t){if(e){if(/^[\d.]+px$/.test(e))return parseFloat(e);if(/^[\d.]+%$/.test(e))return t*parseFloat(e)/100}}function L(e){let t=[];for(let r=e;r;r=y(r))t.unshift(r);return{boxes:t,measure:function(r=!1){let n=e.ownerDocument.documentElement.clientWidth;for(let i of t){let t=getComputedStyle(i);if("inline"===t.display||"contents"===t.display)continue;let o=(parseFloat(t.paddingLeft)||0)+(parseFloat(t.paddingRight)||0)+(parseFloat(t.borderLeftWidth)||0)+(parseFloat(t.borderRightWidth)||0),a="border-box"===t.boxSizing,l=z(A(i,"width"),n),s=z(A(i,"max-width"),n),c=void 0===l?n-o:l-(a?o:0);n=Math.max(0,Math.min(c,void 0===s?1/0:s-(a?o:0))),r&&i===e&&(n+=o)}return n}}}function N(e,t,r){let n={},i=e&&getComputedStyle(e);if(i)for(let e of c)n[e]=i.getPropertyValue(e);let o=d(),a=e=>{let{raisedSurface:t,primary:r}=v[e];return i&&o&&u(o(i.color,t),o(t,t))>=4.5?i.color:r};return{style:n,width:t,fonts:r,lightInk:a("light"),darkInk:a("dark")}}function D(e,t){let r=t.flatMap(e=>"fixture"in e?[e.fixture.bundle]:[]).join(","),[n,i]=k({}),o=S(new Map);return C(()=>{let e=o.current;return i({}),()=>{for(let t of e.values())t.abort();e.clear()}},[e]),C(()=>{let t=o.current;for(let n of r.split(",")){if(!/^[a-f0-9]{64}$/.test(n)||t.has(n))continue;let r=new AbortController;t.set(n,r),w(e+"/files/explore-"+n+".json",{signal:r.signal}).then(async e=>{if(409===e.status)return"The saved recipe could not reproduce the original preview with this checkout.";if(!e.ok)throw Error("This fixture bundle could not be loaded.");let t=await e.json();if("string"!=typeof t.script||"string"!=typeof t.css)throw Error("Invalid fixture bundle.");return t}).catch(()=>"This fixture bundle could not be loaded.").then(e=>{r.signal.aborted||i(t=>({...t,[n]:e}))})}},[e,r]),n}function B({frameKey:e,bundle:t,...r}){let[n,i]=k(null);if("string"==typeof t)return M("div",{className:"sp-steer-frame",role:"alert",children:t});let o=n&&n.key!==e?n:null,a=[];return o&&a.push(M(K,{...o.props,captureRef:void 0,presentation:"retiring"},o.key)),t&&a.push(M(K,{...r,bundle:t,presentation:n?.key===e?"current":"pending",onReady:()=>i({key:e,props:{...r,bundle:t}})},e)),a.length?M(P,{children:a}):M("div",{className:"sp-steer-frame",role:"status",children:"Loading preview…"})}function K(l){let s=b(),c=S(null),p=S(null),d=S(null),u=S(null),h=S(null),m=S({...l,feedbackOnly:s});m.current={...l,feedbackOnly:s};let{toggle:f}=E(j),y=S(f);y.current=f;let[v,w]=k(0),[x,W]=k(""),A=O(()=>{if(l.readOnly&&!l.frozenParent||location.pathname!==l.target.pathname)return null;if("component"===l.previewScope){let{component:e,element:r}=t(l.target);return e??r}return g(l.target.selector,l.target.element)},[l.target,l.previewScope,l.readOnly,l.frozenParent]),{mirror:I,fillScene:z,framing:D,capture:B,readOnly:K}=l,H=O(()=>({script:l.bundle.script,css:l.bundle.css}),[l.bundle.script,l.bundle.css]);C(()=>{c.current&&(c.current.inert="retiring"===l.presentation||"pending"===l.presentation)},[l.presentation]),C(()=>{let e=c.current;if(!v||!e?.contentWindow)return;let{port1:t,port2:l}=new MessageChannel;u.current=t;let s,f=m.current.initial,g=A&&L(A),b="",w=()=>{let e=N(A,g?.measure()??document.documentElement.clientWidth,b);if(B&&(e.width=B.width,e.style=B.style,e.lightInk=e.darkInk=B.style.color||"currentColor"),m.current.pageInk&&(e.lightInk=e.darkInk=m.current.pageInk),p.current){let t=s??{width:p.current.clientWidth,height:p.current.clientHeight};if(I){let r=A&&!z?F(A,g?.measure(!0)??e.width):null;e.slot=r?{width:r.width,height:t.height}:t,r&&(e.intrinsic=r.intrinsic)}else e.surface=B?{width:Math.min(B.viewport.width,t.width),height:Math.min(B.viewport.height,t.height)}:t,A&&Object.assign(e,F(A,e.width))}return e},x=!1,k=e=>{(x||!I)&&t.postMessage(e)},S=()=>k({type:"reference",reference:w(),theme:m.current.theme});h.current=S;let C=new ResizeObserver(e=>{let t=e.find(e=>e.target===p.current)?.contentRect;t&&(s={width:t.width,height:t.height}),S()});for(let e of g?.boxes??[])C.observe(e);p.current&&C.observe(p.current),C.observe(e.ownerDocument.documentElement);let E=!1,O=new AbortController,M=A?r(A,O.signal).then(e=>{!E&&e&&(b=e,S())}).catch(()=>{}):Promise.resolve(),P=I?void 0:R(e,e=>k({type:"controls",bounds:e}),()=>k({type:"controlEnter"})),T=e.closest(".sp-workspace"),j=["wheel","gesturestart","gesturechange","gestureend"],X=t=>{if(!D||"retiring"===m.current.presentation)return;let r=t;if("wheel"===r.type&&!r.ctrlKey&&1===D.getScale())return;t.preventDefault(),t.stopPropagation();let n=e.getBoundingClientRect();k({type:"framingGesture",event:r.type,clientX:r.clientX-n.left,clientY:r.clientY-n.top,deltaX:r.deltaX,deltaY:r.deltaY,deltaMode:r.deltaMode,ctrlKey:r.ctrlKey,scale:r.scale??1})};for(let e of j)T?.addEventListener(e,X,{capture:!0,passive:!1});let Y=JSON.stringify(f),G=!1,U=D?.subscribe(()=>{G||k({type:"framing",view:D.snapshot()})}),V=0,$=!1,J=new Map,q=()=>new Promise((e,t)=>{if(!$||E)return void t(Error("The option is still loading. Try again in a moment."));let r=++V,n=setTimeout(()=>{J.delete(r),t(Error("The preview capture timed out. Please try again."))},8e3);J.set(r,{resolve:e,reject:t,timer:n}),k({type:"capture",id:r,background:m.current.captureBackground??"transparent"})}),Q=m.current.captureRef;Q&&(Q.current=q),t.onmessage=({data:e})=>{if(!E&&"retiring"!==m.current.presentation&&e&&"object"==typeof e)switch(e.type){case"capture":{let t=J.get(e.id);if(!t)break;J.delete(e.id),clearTimeout(t.timer),e.image instanceof Blob&&"image/png"===e.image.type&&e.image.size>0&&e.image.size<=8388608?t.resolve(e.image):t.reject(Error("Could not capture the reviewed option. Please try again."));break}case"edits":if(I||!Array.isArray(e.edits)||e.edits.length>512)return;try{let t=i(f,e.edits.map(e=>{if(!o(e.part,e.property))throw Error();return a({...e,batchId:"",option:0}),e})),r=JSON.stringify(t);Y!==r&&(Y=r,m.current.onChange?.(t))}catch{}break;case"framing":{let{view:t,fit:r}=e;if(!D||!Number.isFinite(r)||r<=0||r>1||!t||!(null===t.pageScale||Number.isFinite(t.pageScale)&&t.pageScale>0&&t.pageScale<=4)||!Number.isFinite(t.focusX)||!Number.isFinite(t.focusY))return;G=!0,D.setFitScale(r),D.restore(t),G=!1;break}case"tag":!I&&"string"==typeof e.part&&n.test(e.part)&&m.current.onTag?.(e.part,"string"==typeof e.label?e.label.slice(0,80):void 0);break;case"preview":m.current.onPreview?.(e.parts);break;case"escape":m.current.onEscape?.();break;case"toggle":I||y.current();break;case"canvas":"boolean"==typeof e.present&&m.current.onCanvas?.(e.present);break;case"ready":$=!0,m.current.onReady?.(),k({type:"interaction",selected:m.current.selected,feedbackOnly:m.current.feedbackOnly}),I&&k({type:"styles",parts:m.current.parts??{}});break;case"size":d.current&&Number.isFinite(e.width)&&Number.isFinite(e.height)&&(d.current.style.height=Math.min(16384,Math.max(1,e.height))+"px",d.current.style.width=Math.min(16384,Math.max(1,e.width))+"px");break;case"error":m.current.onError?.(),I||m.current.onReady?.(),W(String(e.message).slice(0,300))}};let Z=()=>{E||!e.contentWindow||(x=!0,e.contentWindow.postMessage({bundle:H,initial:f,parts:I?m.current.parts:void 0,reference:w(),theme:m.current.theme,accent:m.current.accent,framing:D?.snapshot()??{pageScale:null,focusX:0,focusY:0},feedbackOnly:m.current.feedbackOnly,readOnly:K,mirror:!!I,fillScene:z},"*",[l]))};return I?M.then(Z):Z(),()=>{for(let e of j)T?.removeEventListener(e,X,!0);E=!0,P?.(),C.disconnect(),O.abort(),U?.(),u.current=null,h.current=null,t.close(),Q?.current===q&&(Q.current=null);for(let e of J.values())clearTimeout(e.timer),e.reject(Error("The preview changed before it could be captured. Try again."));J.clear(),m.current.onPreview?.(null)}},[v,H,A,I,z,D,B,K]),C(()=>{u.current?.postMessage({type:"interaction",selected:l.selected,feedbackOnly:s})},[l.selected,s]),C(()=>{u.current?.postMessage({type:"styles",parts:l.parts??{}})},[l.parts]),C(()=>{h.current?.()},[l.theme,l.pageInk]);let X=M("iframe",{ref:c,title:l.frozenParent?"Edited parent at iteration time":K?"Original at exploration time":I?"Explore page preview":"Edit or interact with this option",sandbox:"allow-scripts","aria-hidden":"retiring"===l.presentation||void 0,referrerPolicy:"no-referrer",srcDoc:e,style:{border:0,colorScheme:I?void 0:l.theme,display:"block",position:"absolute",top:B?"max(0px, calc(50% - "+B.viewport.height/2+"px))":0,left:B?"max(0px, calc(50% - "+B.viewport.width/2+"px))":0,width:B?.viewport.width??"100vw",height:B?.viewport.height??"100vh",maxWidth:"none",maxHeight:"none",opacity:"pending"===l.presentation?0:1},onLoad:()=>w(e=>e+1)});return T(P,{children:[T("span",{ref:p,className:I?void 0:"sp-steer-frame",style:{display:"block",overflow:"clip",...I?{position:"relative",minWidth:0,height:z?"100%":void 0}:{gridArea:"1 / 1"}},children:[I&&!z&&M("span",{ref:d,"aria-hidden":"true",style:{display:"block",maxWidth:"100%"}}),X]}),x&&M("span",{role:"alert",children:x})]})}function H(e){return Object.fromEntries(Object.entries(e??{}).map(([e,t])=>[e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase()),t]))}function X({node:e,picker:t,path:r=[],live:n}){let i="row"===e.kind||"column"===e.kind,o=r.join("."),a={display:"inline-flex",flexDirection:"column"===e.kind?"column":"row",alignItems:i&&"column"===e.kind?"flex-start":"center",gap:e.space??0,flexWrap:i&&"row"===e.kind?"inherit":void 0,maxWidth:"100%",boxSizing:"border-box",color:e.ink,background:e.fill,border:e.stroke?"1px solid "+e.stroke:void 0,borderRadius:e.radius,padding:e.px||e.py?String(e.py??0)+"px "+String(e.px??0)+"px":void 0,fontSize:e.size?e.size+"px":void 0,fontWeight:e.weight,...H(e.style),...H(n?.[o])},l=o+"/label",s=!i&&"text"!==e.kind;return T("span",{style:a,className:[t&&"sp-piece"].filter(Boolean).join(" ")||void 0,"data-sp-fill":t&&(e.fill||a.backgroundColor)?"":void 0,"data-sp-ink":t&&a.color?"":void 0,"data-scratch-text":"text"===e.kind||void 0,"data-popmelt-label":p(e),"data-scratch-part":o,tabIndex:t?-1:void 0,"data-badge-hover":t?.hovered===o||void 0,"data-tagged":t?.selected===o||void 0,children:[t&&M("button",{type:"button",className:"sp-piece-hit",onClick:()=>t.tag(o),"aria-label":`Tag ${e.kind}${e.label?": "+e.label:""}`,"aria-pressed":t.selected===o}),i?e.children?.map((e,i)=>M(X,{live:n,node:e,path:[...r,i],picker:t},i)):t&&s?M("button",{type:"button",className:"sp-label-hit","data-popmelt-label":p(e,"label"),"data-sp-fill":e.labelStyle?.["background-color"]?"":void 0,"data-sp-ink":e.labelStyle?.color?"":void 0,"data-scratch-text":"",style:H(e.labelStyle),"data-scratch-part":l,"data-badge-hover":t.hovered===l||void 0,"data-tagged":t.selected===l||void 0,onClick:()=>t.tag(l),"aria-label":"Tag text: "+e.label,"aria-pressed":t.selected===l,children:n?.[l]?.text??e.label}):s?M("span",{"data-popmelt-label":p(e,"label"),"data-scratch-part":l,style:{display:"inline-block",...H(e.labelStyle),...H(n?.[l])},children:n?.[l]?.text??e.label}):n?.[o]?.text??e.label]})}function Y({element:e,scene:t,active:r,revealOnPage:n,children:i}){let[o,a]=k(null);return C(()=>{let r=e.ownerDocument,n=r.createElement("span");n.dataset.popmeltExploreCache="",n.setAttribute("inert","");let i=!t&&(e.hasAttribute("data-popmelt-explore-original")?h(e)??e:e),o=getComputedStyle(i||e);if(t)n.style.cssText="position:absolute;inset:0;display:block;overflow:hidden";else{if(n.style.display=o.display.startsWith("inline")?"inline-flex":"block","absolute"===o.position||"fixed"===o.position)for(let e of["position","top","right","bottom","left","z-index","transform","transform-origin"])n.style.setProperty(e,o.getPropertyValue(e));if("inline"!==o.display)for(let t of["width","max-width"]){let r=A(i||e,t);r&&n.style.setProperty(t,r)}for(let e of[...c,"align-self","grid-area","margin"])n.style.setProperty(e,o.getPropertyValue(e))}let l=n.style.cssText;n.style.visibility="hidden",t||(n.style.position="fixed",n.style.left="0",n.style.top="0",n.style.width=L(e).measure()+"px",n.style.height="0",n.style.overflow="clip");let s=r.createElement("style");return s.textContent="[data-popmelt-explore-original] { display: none !important; } [data-popmelt-explore-scene] > :not([data-popmelt-explore-preview]) { opacity: 0 !important; pointer-events: none !important; } [data-popmelt-explore-scene-position] { position: relative !important; }",t?(n.append(s),e.append(n)):e.before(s,n),a({host:n,style:l,position:"static"===o.position||e.hasAttribute("data-popmelt-explore-scene-position")}),()=>{n.remove(),s.remove()}},[e,t]),C(()=>{if(!o||!r)return;let{host:n,style:i,position:a}=o,l=n.style.cssText;n.style.cssText=i,n.dataset.popmeltExplorePreview="";let s=t?"data-popmelt-explore-scene":"data-popmelt-explore-original";t&&a&&e.setAttribute("data-popmelt-explore-scene-position",""),e.setAttribute(s,"");let c=m(e,n);return()=>{e.removeAttribute(s),t&&a&&e.removeAttribute("data-popmelt-explore-scene-position"),n.removeAttribute("data-popmelt-explore-preview"),n.style.cssText=l,c()}},[o,e,t,r]),C(()=>{if(!o||!r||!n)return;let e=requestAnimationFrame(()=>o.host.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"}));return()=>cancelAnimationFrame(e)},[o,r,n]),o&&W(i,o.host)}function G({preview:e,active:r,onReady:n}){let{option:i,target:o,bundle:a,parts:c,theme:p,accentColor:d,hasCanvas:u,revealOnPage:h}=e,[m,f]=k(e.targets),[g,y]=k(null);C(()=>f(e.targets),[e.targets]);let b="fixture"in i?l(m,i.previewScope,u):m.element;if(C(()=>{let e=()=>{if(b?.isConnected)return;let e=t(o);(e.element!==m.element||e.component!==m.component||e.legacyScene!==m.legacyScene)&&f(e)},r=new MutationObserver(e);return r.observe(document,{subtree:!0,childList:!0}),e(),()=>r.disconnect()},[b,o,m]),C(()=>{!("fixture"in i)&&b?.isConnected&&n()},[i,b,n]),!b?.isConnected)return null;let v="fixture"in i&&(s(b)===b||(b===m.component||b===m.legacyScene)&&!!b.querySelector("canvas"));return M(Y,{element:b,scene:v,active:r&&(!("fixture"in i)||g?.element===b&&g.scene===v),revealOnPage:h,children:"fixture"in i?a&&M(K,{mirror:!0,fillScene:v,bundle:a,target:o,previewScope:i.previewScope,theme:p,accent:d,initial:[],parts:c,onReady:()=>{y({element:b,scene:v}),n()}}):M(X,{node:i.root,live:c})})}function U({preview:e}){let t=e.index>=0?(e=>e.threadId+":"+e.batchId+":"+e.index+("fixture"in e.option?":"+e.option.fixture.bundle:""))(e):null,[r,n]=k([]),[i,o]=k(null),a=r.find(e=>e.key===t),l=e.enabled&&!e.suspended&&null!==t?a?.ready?t:i:null;return C(()=>{l!==i&&o(l)},[l,i]),C(()=>{!t||"fixture"in e.option&&!e.bundle||n(r=>{let n=r.find(e=>e.key===t),o=r.filter(e=>e.key!==t);for(;o.length>2;){let e=o.findIndex(e=>e.key!==i);o.splice(e,1)}return[...o,{key:t,preview:e,ready:n?.ready??!1}]})},[t,e,i]),M(P,{children:r.map(r=>M(G,{preview:r.key===t?e:r.preview,active:e.enabled&&!e.suspended&&null!==t&&r.key===l,onReady:()=>n(e=>e.some(e=>e.key===r.key&&!e.ready)?e.map(e=>e.key===r.key?{...e,ready:!0}:e):e)},r.key))})}export{j as a,R as b,D as c,B as d,K as e,U as f};
@@ -0,0 +1 @@
1
+ import{a as t}from"./chunk-KD2AOPYP.mjs";import{mkdir as r,readFile as e,realpath as o}from"fs/promises";import{existsSync as s}from"fs";import{createServer as a}from"net";import{homedir as i}from"os";import{join as n}from"path";import{pairedAppOrigins as l,projectKeyFor as p,writePrivate as c}from"../infra/phone-pairing/binding.mjs";function h(t,r){return new Promise((e,o)=>{let s=a();s.once("error",t=>{"EADDRINUSE"===t.code||"EACCES"===t.code?e(!1):"::1"===r&&["EAFNOSUPPORT","EADDRNOTAVAIL"].includes(t.code??"")?e(!0):o(t)}),s.listen(t,r,()=>s.close(()=>e(!0)))})}async function m(a,m,{records:f=n(i(),".popmelt-pair"),listenHost:d}={}){let u=await o(a);return await r(f,{recursive:!0,mode:448}),t(n(f,"dev-ports.lock"),async()=>{let{own:t,reserved:r}=l(u,f),o=t=>void 0===d||["localhost","127.0.0.1","::1"].includes(d??"")||h(t,d??void 0),a=async t=>await h(t,"127.0.0.1")&&await h(t,"::1");if(t){let r=Number(t.port),e="[::1]"===t.hostname?"::1":t.hostname;if(("localhost"===e?await a(r):await h(r,e))&&await o(r))return{port:r,hostname:t.hostname}}let i=n(f,"dev-ports.json"),w=new Map(s(i)?JSON.parse(await e(i,"utf8")):[]),v=w.get(u);w.delete(u);for(let[e,o]of w)s(e)?r.has(o)||((t||r.size>0)&&s(n(f,p(e,f)+".json"))?w.delete(e):r.add(o)):w.delete(e);let P=async t=>!r.has(t)&&await a(t)&&o(t);if(v&&await P(v))return{port:v,...t&&{hostname:t.hostname}};for(let r=m;r<=65535;r++)if(await P(r))return w.set(u,r),c(i,JSON.stringify([...w])),{port:r,...t&&{hostname:t.hostname}};throw Error("No loopback app port is available for this project.")})}function f(t,r){if(!t||"localhost"===t)return;let e="[::1]"===t?"::1":t;if(("::1"===r||"127.0.0.1"===r)&&r!==e)throw Error(`This project's phone bookmark uses ${e}. Use that loopback host for this dev server.`);return e}function d(t){return null==t.server?.port&&!t.server?.strictPort}function u(t,r){let e=t.config.server;if(!t.httpServer||5173!==e.port||e.middlewareMode||e.https||e.strictPort||e.host&&!["localhost","127.0.0.1","::1"].includes(String(e.host)))return;let o=t.listen;t.listen=async function(t,s){if(void 0!==t&&!s)return o.call(this,t,s);let a=await m(r,e.port),i=f(a.hostname,e.host);return i&&(e.host=i),e.port=a.port,e.strictPort=!0,o.call(this,a.port,s)}}export{m as a,f as b,d as c,u as d};
@@ -1 +1 @@
1
- import{a as e,b as t}from"./chunk-HKHZBKAN.mjs";import{createServer as a}from"http";import{readFile as i,realpath as r,stat as s}from"fs/promises";import{extname as o,join as n}from"path";var d={".html":"text/html; charset=utf-8",".htm":"text/html; charset=utf-8",".css":"text/css",".js":"text/javascript",".mjs":"text/javascript",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".svg":"image/svg+xml",".gif":"image/gif",".avif":"image/avif",".webp":"image/webp",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf"};async function m(m,p=0,c){let f=await r(m),l=a((a,m)=>{if(m.setHeader("Cache-Control","no-store"),m.setHeader("X-Content-Type-Options","nosniff"),a.headers.host!==new URL(w).host)return void m.writeHead(403).end();let p=()=>{(async()=>{if("GET"!==a.method&&"HEAD"!==a.method)return void m.writeHead(405).end();let p=new URL(a.url??"/",w);if(c&&p.pathname===e)return void m.writeHead(200,{"Content-Type":"text/javascript"}).end("HEAD"===a.method?void 0:await t("toolbar"));let l=decodeURIComponent(p.pathname);if(/[\\%]/.test(l)||l.includes("\0")||l.split("/").some(e=>e.startsWith(".")||"node_modules"===e))return void m.writeHead(404).end();let h=n(f,l);(await s(h)).isDirectory()&&(h=n(h,"index.html"));let g=d[o(h).toLowerCase()];if(!g||await r(h)!==h||!(await s(h)).isFile())return void m.writeHead(404).end();let v=await i(h);if(c&&g.startsWith("text/html")){let t="<script>window.__POPMELT_PARTICIPANTS__="+JSON.stringify(await c.read(l)).replace(/</g,"\\u003c")+'<\/script><script defer src="'+e+'"><\/script>',a=v.toString();v=/<\/head\s*>/i.test(a)?a.replace(/<\/head\s*>/i,()=>t+"</head>"):a.replace(/^(\s*<!doctype[^>]*>)?/i,e=>e+t)}m.writeHead(200,{"Content-Type":g}).end("HEAD"===a.method?void 0:v)})().catch(()=>m.writeHead(404).end())};c?c.middleware(a,m,p):p()}),w="";return await new Promise((e,t)=>l.once("error",t).listen(p,"127.0.0.1",e)),w="http://127.0.0.1:"+l.address().port,{origin:w,isRunning:()=>l.listening,close:async()=>{let e=new Promise(e=>l.close(()=>e()));l.closeAllConnections(),await e}}}export{m as a};
1
+ import{a as e,b as t}from"./chunk-HKHZBKAN.mjs";import{createServer as a}from"http";import{readFile as i,realpath as r,stat as s}from"fs/promises";import{extname as o,join as n}from"path";var d={".html":"text/html; charset=utf-8",".htm":"text/html; charset=utf-8",".css":"text/css",".js":"text/javascript",".mjs":"text/javascript",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".svg":"image/svg+xml",".gif":"image/gif",".avif":"image/avif",".webp":"image/webp",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf"};async function m(m,p=0,c){let f=await r(m),l=a((a,m)=>{if(m.setHeader("Cache-Control","no-store"),m.setHeader("X-Content-Type-Options","nosniff"),a.headers.host!==new URL(w).host)return void m.writeHead(403).end();let p=()=>{(async()=>{if("GET"!==a.method&&"HEAD"!==a.method)return void m.writeHead(405).end();let p=new URL(a.url??"/",w);if(c&&p.pathname===e)return void m.writeHead(200,{"Content-Type":"text/javascript"}).end("HEAD"===a.method?void 0:await t("toolbar"));let l=decodeURIComponent(p.pathname);if(/[\\%]/.test(l)||l.includes("\0")||l.split("/").some(e=>e.startsWith(".")||"node_modules"===e))return void m.writeHead(404).end();let h=n(f,l);(await s(h)).isDirectory()&&(h=n(h,"index.html"));let g=d[o(h).toLowerCase()];if(!g||await r(h)!==h||!(await s(h)).isFile())return void m.writeHead(404).end();let v=await i(h);if(c&&g.startsWith("text/html")){let t="<script>window.__POPMELT_PARTICIPANTS__="+JSON.stringify(await c.read(l)).replace(/</g,"\\u003c")+'<\/script><script defer src="'+e+'"><\/script>',a=v.toString();v=/<\/head\s*>/i.test(a)?a.replace(/<\/head\s*>/i,()=>t+"</head>"):a.replace(/^(\s*<!doctype[^>]*>)?/i,e=>e+t)}m.writeHead(200,{"Content-Type":g}).end("HEAD"===a.method?void 0:v)})().catch(()=>m.writeHead(404).end())};c?c.middleware(a,m,p):p()}),h=c?.hostname??"127.0.0.1",w="";return await new Promise((e,t)=>l.once("error",t).listen(p,"[::1]"===h?"::1":h,e)),w=`http://${h}:${l.address().port}`,{server:l,origin:w,isRunning:()=>l.listening,close:async()=>{let e=new Promise(e=>l.close(()=>e()));l.closeAllConnections(),await e}}}export{m as a};
@@ -0,0 +1 @@
1
+ "use client";import{f as e}from"./chunk-VXRRHXUP.mjs";import{e as t,f as n}from"./chunk-AAMUU2QA.mjs";import{u as r,d as a}from"./chunk-LH7HKUCK.mjs";import{createContext as i}from"react";function o(e,t){let n=r(e.filter(e=>!e.includes("data-pm=")),t);return"matched"===n.status?n.element:null}function l(e){if(!e||!/^\/(?!\/)/.test(e)||/[\\?#\s]/.test(e))return;let t=n(e);return t.startsWith("//")||t.startsWith("/__popmelt/")?void 0:new URL(t,"https://local.invalid").pathname===t?t:void 0}function s(e){let t,n=e.messages?.find(e=>"human"===e.role),r=n?.annotationSnapshot;try{if(r?.url){let e=new URL(r.url,r.url.startsWith("/")?"http://localhost":void 0);/^https?:$/.test(e.protocol)&&(t=e)}}catch{}let a=r?.annotations?.[0],i=n?.requestItems?.find(e=>"changes"===e.kind),o=(e.targetBindings??[]).map(e=>e.anchor),s=o.find(e=>"dom"===e.type),c=[...e.elementIdentifiers??[],...i?[i.elementKey]:[]],h=l(t?.pathname),m=l(s?.pathname)??l(a?.pathname)??l(i?.pathname)??l(c.find(e=>e.startsWith("/")&&e.includes(":"))?.split(":")[0])??h,p=o.filter(e=>"opaque"===e.type||l(e.pathname)===m),f=!a||a.pathname&&l(a.pathname)!==m?void 0:a;f?.target&&p.push({type:"opaque",...f.target});let u=f?.elements?.[0];!f?.region&&(f?.linkedSelector||u)&&p.push({type:"dom",pathname:m??"/",structuralSelector:u?.selector,runtimeSelector:f?.linkedSelector,targetFingerprint:u?.targetFingerprint});for(let e of c){let t=e.indexOf(":"),n=e.startsWith("/")?t>0&&l(e.slice(0,t))===m?e.slice(t+1):"":h&&h===m?e:"";n&&p.push({type:"dom",pathname:m??"/",structuralSelector:n})}let g=f?.region;if(!(p.length||g?.points.length||f||i))return null;let d=h===m&&t?t.search+t.hash:"";return{pathname:m,href:m&&m+d,targets:p,region:g,element:u}}function c(e){return n(location.pathname)+location.search+location.hash===e}function h(e){try{let t=sessionStorage.getItem(e);if(!t)return;sessionStorage.removeItem(e);let n=JSON.parse(t);if(n.expires>Date.now()&&"string"==typeof n.id&&c(n.href))return n.id}catch{}}function m(n,r,i){let l,s=!1,m=new AbortController,p=()=>{s=!0,clearTimeout(l),m.abort()};for(let e of["wheel","pointerdown","touchstart","keydown"])window.addEventListener(e,p,{capture:!0,passive:!0,signal:m.signal});let{href:f}=r;return async function(){if(f&&!c(f)){try{sessionStorage.setItem(i.storageKey,JSON.stringify({id:n,href:f,expires:Date.now()+3e4}))}catch{}if(i.navigate)await i.navigate(f);else{let e=new URL(t(location.pathname).slice(0,-1)+f,location.origin),n=e.pathname!==location.pathname||e.search!==location.search;if(location.assign(e.href),n)return}}let m=performance.now()+4e3,u=!1,g=null,d=0,w=!1,y=window.matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":"smooth",v=async()=>{if(!s){if(!f||c(f)){!w&&f&&h(i.storageKey),w=!0;let t=g?.isConnected?g:function(e,t){for(let n of e)if("opaque"===n.type){let e=t.resolve(n);if(e)return e.subject.sourceElement??e.element}else{let e=[n.structuralSelector,n.runtimeSelector,...n.legacySelectors??[]].filter(e=>!!e),t=o(e,n.targetFingerprint);if(t)return t}return null}(r.targets,i.registry);if(t){for(let e=t.parentElement;e;e=e.parentElement)e instanceof HTMLDetailsElement&&!e.open&&(e.open=!0);let e=a(t),n=e.bottom<=0||e.top>=innerHeight||e.right<=0||e.left>=innerWidth;e.height&&e.width&&(g!==t||n&&performance.now()-d>750)&&(t.scrollIntoView({behavior:g?"instant":y,block:"center",inline:"nearest"}),g=t,d=performance.now())}if(!g&&!u&&r.element?.revealRecipe&&(u=!0,await e(void 0,[r.element]),s))return;if(!t&&r.region?.points.length){let e=r.region.points.map(e=>e.x),t=r.region.points.map(e=>e.y);return window.scrollTo({left:(Math.min(...e)+Math.max(...e)-innerWidth)/2,top:(Math.min(...t)+Math.max(...t)-innerHeight)/2,behavior:y}),p()}if(!r.targets.length)return p()}else if(w)return p();performance.now()<m?l=setTimeout(()=>{v().catch(p)},g?250:160):p()}};await v()}().catch(p),p}var p=i(null),f=i(void 0);export{o as a,s as b,h as c,m as d,p as e,f};