@popmelt.com/core 0.37.1 → 0.38.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 (137) hide show
  1. package/THIRD_PARTY_NOTICES.md +236 -0
  2. package/claude-plugin/.claude-plugin/plugin.json +1 -1
  3. package/codex-plugin/.codex-plugin/plugin.json +1 -1
  4. package/dist/ExploreAttachment-IIEORQP3.mjs +1 -0
  5. package/dist/{PagePreviewLayer-SIH7DDBF.mjs → PagePreviewLayer-AFSRCBAX.mjs} +1 -1
  6. package/dist/ParticipantRuntime-CGJH7YZL.mjs +1 -0
  7. package/dist/PhoneHostGate-OCIMKPLM.mjs +1 -0
  8. package/dist/PopmeltTasteConnectedPane-N2A5XPRO.mjs +1 -0
  9. package/dist/PreviewRuntime-3ANAJNFO.mjs +1 -0
  10. package/dist/QueuedReplies-5YG2DN3W.mjs +1 -0
  11. package/dist/SamplePlacementOverlay-EOJW6XGE.mjs +1 -0
  12. package/dist/ShareProjectPane-VYWTF3FW.mjs +1 -0
  13. package/dist/SuppliedContext-3S4HT6U6.mjs +1 -0
  14. package/dist/ThreadErrorCard-CTMVMETS.mjs +1 -0
  15. package/dist/ThreadPanel-G7OKSWD4.mjs +1 -0
  16. package/dist/adapter-react-three-fiber.d.mts +1 -1
  17. package/dist/adapter-react-three-fiber.mjs +1 -1
  18. package/dist/adapter-three.d.mts +2 -0
  19. package/dist/adapter-three.mjs +3 -3
  20. package/dist/bridge-entry.mjs +1 -1
  21. package/dist/bridge-recovery-NUYIGCFV.mjs +1 -0
  22. package/dist/bridgeSSEStream-HUFNXYPG.mjs +1 -0
  23. package/dist/bridgeWebSocketStream-AS22Y2FP.mjs +1 -0
  24. package/dist/browser-runtime-WXDKC4TL.mjs +1 -0
  25. package/dist/browser.d.mts +4 -4
  26. package/dist/browser.mjs +1 -1
  27. package/dist/canvas-chat-note-OLVVP55Y.mjs +1 -0
  28. package/dist/checkFixture-UNTXJKRN.mjs +1 -0
  29. package/dist/{chunk-YYODLRV3.mjs → chunk-25EXQOPI.mjs} +1 -1
  30. package/dist/{chunk-L6S66APQ.mjs → chunk-2F2BVGFH.mjs} +1 -1
  31. package/dist/chunk-2GICKLUW.mjs +1 -0
  32. package/dist/chunk-3DUTQ6GY.mjs +1 -0
  33. package/dist/{chunk-76WRZ2NH.mjs → chunk-3LZQLRZ2.mjs} +1 -1
  34. package/dist/{chunk-IAXSC2ZN.mjs → chunk-43BZCDGL.mjs} +1 -1
  35. package/dist/{chunk-7EISKUU7.mjs → chunk-5F34UIKL.mjs} +1 -1
  36. package/dist/{chunk-ECMLCGAM.mjs → chunk-6RMM7JB6.mjs} +1 -1
  37. package/dist/{chunk-3PSB5BST.mjs → chunk-6V4Q2JFN.mjs} +1 -1
  38. package/dist/{chunk-CVVD2OMQ.mjs → chunk-7MYZEG74.mjs} +1 -1
  39. package/dist/{chunk-JSNK6NX7.mjs → chunk-ACBGA4NT.mjs} +1 -1
  40. package/dist/{chunk-B22WBEQC.mjs → chunk-B3RA4XAR.mjs} +1 -1
  41. package/dist/{chunk-FON4QY7P.mjs → chunk-BEGAJYOY.mjs} +1 -1
  42. package/dist/{chunk-6XEEXK3U.mjs → chunk-BJUSVIDN.mjs} +1 -1
  43. package/dist/chunk-BOZVNUHJ.mjs +1 -0
  44. package/dist/chunk-BRAEIDNX.mjs +30 -0
  45. package/dist/chunk-CRZEJJI6.mjs +1 -0
  46. package/dist/{chunk-O2ZQFLNV.mjs → chunk-DBCBG5J6.mjs} +1 -1
  47. package/dist/{chunk-RUJC32MA.mjs → chunk-EFWBHWHP.mjs} +1 -1
  48. package/dist/{chunk-EZVFCJEG.mjs → chunk-FYURSPM3.mjs} +1 -1
  49. package/dist/{chunk-HPU2UMVE.mjs → chunk-G6BN5TAZ.mjs} +1 -1
  50. package/dist/chunk-GTVTUWGH.mjs +1 -0
  51. package/dist/{chunk-SKKHZBOJ.mjs → chunk-JAMYVQFC.mjs} +1 -1
  52. package/dist/{chunk-SOT33EQ4.mjs → chunk-JJRKR4X3.mjs} +1 -1
  53. package/dist/{chunk-EFGQKWSZ.mjs → chunk-KHDXOXYF.mjs} +1 -1
  54. package/dist/chunk-KL5ODVJA.mjs +1 -0
  55. package/dist/{chunk-WF3YGZPI.mjs → chunk-L356S4EY.mjs} +1 -1
  56. package/dist/{chunk-WJHYEACV.mjs → chunk-O2OYVEL7.mjs} +1 -1
  57. package/dist/{chunk-QV5G3XRE.mjs → chunk-P2WAXWAZ.mjs} +1 -1
  58. package/dist/{chunk-EUFR7R5Q.mjs → chunk-QXFBFKN6.mjs} +1 -1
  59. package/dist/{chunk-KXVXWEN4.mjs → chunk-RJWFSAKE.mjs} +1 -1
  60. package/dist/{chunk-FJWWBKCQ.mjs → chunk-RWZ7SVMO.mjs} +1 -1
  61. package/dist/{chunk-GAUQZAW6.mjs → chunk-SKM4ZXV5.mjs} +1 -1
  62. package/dist/{chunk-EBJ23A7F.mjs → chunk-TEXVTTWA.mjs} +1 -1
  63. package/dist/{chunk-QXVMGZFP.mjs → chunk-TSQEBZYO.mjs} +1 -1
  64. package/dist/{chunk-JEGBAHYK.mjs → chunk-TVIKC33M.mjs} +1 -1
  65. package/dist/{chunk-4LVGVKSS.mjs → chunk-TXL2CR66.mjs} +1 -1
  66. package/dist/{chunk-SBD7GQDN.mjs → chunk-W62YY5IT.mjs} +1 -1
  67. package/dist/{chunk-BYASSHKJ.mjs → chunk-WIJSWSNF.mjs} +1 -1
  68. package/dist/{chunk-NI77Y3WC.mjs → chunk-WJVRGXOS.mjs} +1 -1
  69. package/dist/{chunk-HAN6CUNB.mjs → chunk-WNOLXY3Y.mjs} +1 -1
  70. package/dist/{chunk-HBFSPXIC.mjs → chunk-X56HNVHF.mjs} +1 -1
  71. package/dist/{chunk-UX3DTCHL.mjs → chunk-Y3WTPLDG.mjs} +1 -1
  72. package/dist/chunk-YGP6PPOZ.mjs +1 -0
  73. package/dist/{chunk-LOUWY55X.mjs → chunk-ZHXTB5IN.mjs} +1 -1
  74. package/dist/chunk-ZSTKAPV5.mjs +24 -0
  75. package/dist/cli.mjs +1 -1
  76. package/dist/codex-note-context-WYH7D6SS.mjs +1 -0
  77. package/dist/{codex-project-3GJPU63O.mjs → codex-project-Q4CKTDOH.mjs} +1 -1
  78. package/dist/{codex-store-mount-F6RBC77X.mjs → codex-store-mount-RSRKEV2B.mjs} +1 -1
  79. package/dist/dev-server-SDS67665.mjs +1 -0
  80. package/dist/focus-inspection-LGIRFL2T.mjs +1 -0
  81. package/dist/guest-admission.mjs +1 -1
  82. package/dist/guest-live-canvas.mjs +1 -1
  83. package/dist/index.d.mts +27 -6
  84. package/dist/index.mjs +1 -1
  85. package/dist/inviteQr-YK3JAR6U.mjs +1 -0
  86. package/dist/media.d.mts +3 -3
  87. package/dist/media.mjs +1 -1
  88. package/dist/memory-legacy.mjs +1 -1
  89. package/dist/memory-store.mjs +1 -1
  90. package/dist/{participantBootstrap-CSLsiQ-C.d.mts → participantBootstrap-BTcD7XgB.d.mts} +2 -2
  91. package/dist/{peer-client-7X52EKMX.mjs → peer-client-HYSUL7UZ.mjs} +1 -1
  92. package/dist/plugin-astro.mjs +1 -1
  93. package/dist/plugin-nuxt.mjs +1 -1
  94. package/dist/plugin-vite.mjs +1 -1
  95. package/dist/server.mjs +1 -1
  96. package/dist/{subjects-BQFCkehy.d.mts → subjects-D_yanOQ2.d.mts} +2 -0
  97. package/dist/taste-proposal-session-AAXK4CFL.mjs +1 -0
  98. package/dist/toolbarFonts-JAGSN3DN.mjs +1 -0
  99. package/dist/{video-adapter-C0kSwUir.d.mts → video-adapter-CWpR4NSt.d.mts} +1 -1
  100. package/dist/webpEncoder-MTPCVDOG.mjs +1 -0
  101. package/dist/workspace-snapshot-RUGPDEYJ.mjs +1 -0
  102. package/package.json +26 -35
  103. package/dist/ExploreAttachment-6AIMXC2K.mjs +0 -1
  104. package/dist/ParticipantRuntime-RTMEFDKF.mjs +0 -1
  105. package/dist/PhoneHostGate-RZRGWS2E.mjs +0 -1
  106. package/dist/PopmeltTasteConnectedPane-FAJXJEQQ.mjs +0 -1
  107. package/dist/PreviewRuntime-MW33PLMV.mjs +0 -1
  108. package/dist/QueuedReplies-4APDDNQX.mjs +0 -1
  109. package/dist/SamplePlacementOverlay-2VLBRDPZ.mjs +0 -1
  110. package/dist/ShareProjectPane-OR2LS2A3.mjs +0 -1
  111. package/dist/SuppliedContext-SAQKEDWW.mjs +0 -1
  112. package/dist/ThreadErrorCard-OSHIWSHR.mjs +0 -1
  113. package/dist/ThreadPanel-CMC5Q6WM.mjs +0 -1
  114. package/dist/bridge-recovery-3IQN3U6D.mjs +0 -1
  115. package/dist/bridgeSSEStream-6OMAFDFW.mjs +0 -1
  116. package/dist/bridgeWebSocketStream-WIOGOPJW.mjs +0 -1
  117. package/dist/browser-runtime-5W2ZKUCZ.mjs +0 -1
  118. package/dist/canvas-chat-note-O3USBECW.mjs +0 -1
  119. package/dist/checkFixture-DQPLFEUL.mjs +0 -1
  120. package/dist/chunk-3QYA5LGF.mjs +0 -1
  121. package/dist/chunk-5GEBVPTA.mjs +0 -1
  122. package/dist/chunk-7JWADHTH.mjs +0 -1
  123. package/dist/chunk-CCFTIBCJ.mjs +0 -1
  124. package/dist/chunk-OIKFQ2FV.mjs +0 -1
  125. package/dist/chunk-QE5XGXIA.mjs +0 -30
  126. package/dist/chunk-ROKRMYFR.mjs +0 -1
  127. package/dist/chunk-VVNZ5IEG.mjs +0 -24
  128. package/dist/codex-note-context-6QGJT2V3.mjs +0 -1
  129. package/dist/dev-server-KWVIMLLL.mjs +0 -1
  130. package/dist/focus-inspection-F25RXWZV.mjs +0 -1
  131. package/dist/inviteQr-U77MLSEQ.mjs +0 -1
  132. package/dist/taste-proposal-session-DBOUA54V.mjs +0 -1
  133. package/dist/toolbarFonts-GVPRHJGB.mjs +0 -1
  134. package/dist/workspace-snapshot-6LN7U2NJ.mjs +0 -1
  135. /package/dist/{chunk-PWQB3FIW.mjs → chunk-AWWUJO3N.mjs} +0 -0
  136. /package/dist/{chunk-TIAPJGX2.mjs → chunk-FIOGWEZA.mjs} +0 -0
  137. /package/dist/{chunk-W2QQVB2H.mjs → chunk-VXRRHXUP.mjs} +0 -0
@@ -121,3 +121,239 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
121
121
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
122
122
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
123
123
  SOFTWARE.
124
+
125
+ ## jSquash WebP encoder
126
+
127
+ Core bundles the scalar WebP encoder from @jsquash/webp 1.5.0 for browsers without native canvas WebP export.
128
+
129
+ Copyright (c) 2010, Google Inc. All rights reserved.
130
+
131
+ Redistribution and use in source and binary forms, with or without
132
+ modification, are permitted provided that the following conditions are
133
+ met:
134
+
135
+ * Redistributions of source code must retain the above copyright
136
+ notice, this list of conditions and the following disclaimer.
137
+
138
+ * Redistributions in binary form must reproduce the above copyright
139
+ notice, this list of conditions and the following disclaimer in
140
+ the documentation and/or other materials provided with the
141
+ distribution.
142
+
143
+ * Neither the name of Google nor the names of its contributors may
144
+ be used to endorse or promote products derived from this software
145
+ without specific prior written permission.
146
+
147
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
148
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
149
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
150
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
151
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
152
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
153
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
154
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
155
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
156
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
157
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
158
+
159
+ Apache License
160
+ Version 2.0, January 2004
161
+ http://www.apache.org/licenses/
162
+
163
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
164
+
165
+ 1. Definitions.
166
+
167
+ "License" shall mean the terms and conditions for use, reproduction,
168
+ and distribution as defined by Sections 1 through 9 of this document.
169
+
170
+ "Licensor" shall mean the copyright owner or entity authorized by
171
+ the copyright owner that is granting the License.
172
+
173
+ "Legal Entity" shall mean the union of the acting entity and all
174
+ other entities that control, are controlled by, or are under common
175
+ control with that entity. For the purposes of this definition,
176
+ "control" means (i) the power, direct or indirect, to cause the
177
+ direction or management of such entity, whether by contract or
178
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
179
+ outstanding shares, or (iii) beneficial ownership of such entity.
180
+
181
+ "You" (or "Your") shall mean an individual or Legal Entity
182
+ exercising permissions granted by this License.
183
+
184
+ "Source" form shall mean the preferred form for making modifications,
185
+ including but not limited to software source code, documentation
186
+ source, and configuration files.
187
+
188
+ "Object" form shall mean any form resulting from mechanical
189
+ transformation or translation of a Source form, including but
190
+ not limited to compiled object code, generated documentation,
191
+ and conversions to other media types.
192
+
193
+ "Work" shall mean the work of authorship, whether in Source or
194
+ Object form, made available under the License, as indicated by a
195
+ copyright notice that is included in or attached to the work
196
+ (an example is provided in the Appendix below).
197
+
198
+ "Derivative Works" shall mean any work, whether in Source or Object
199
+ form, that is based on (or derived from) the Work and for which the
200
+ editorial revisions, annotations, elaborations, or other modifications
201
+ represent, as a whole, an original work of authorship. For the purposes
202
+ of this License, Derivative Works shall not include works that remain
203
+ separable from, or merely link (or bind by name) to the interfaces of,
204
+ the Work and Derivative Works thereof.
205
+
206
+ "Contribution" shall mean any work of authorship, including
207
+ the original version of the Work and any modifications or additions
208
+ to that Work or Derivative Works thereof, that is intentionally
209
+ submitted to Licensor for inclusion in the Work by the copyright owner
210
+ or by an individual or Legal Entity authorized to submit on behalf of
211
+ the copyright owner. For the purposes of this definition, "submitted"
212
+ means any form of electronic, verbal, or written communication sent
213
+ to the Licensor or its representatives, including but not limited to
214
+ communication on electronic mailing lists, source code control systems,
215
+ and issue tracking systems that are managed by, or on behalf of, the
216
+ Licensor for the purpose of discussing and improving the Work, but
217
+ excluding communication that is conspicuously marked or otherwise
218
+ designated in writing by the copyright owner as "Not a Contribution."
219
+
220
+ "Contributor" shall mean Licensor and any individual or Legal Entity
221
+ on behalf of whom a Contribution has been received by Licensor and
222
+ subsequently incorporated within the Work.
223
+
224
+ 2. Grant of Copyright License. Subject to the terms and conditions of
225
+ this License, each Contributor hereby grants to You a perpetual,
226
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
227
+ copyright license to reproduce, prepare Derivative Works of,
228
+ publicly display, publicly perform, sublicense, and distribute the
229
+ Work and such Derivative Works in Source or Object form.
230
+
231
+ 3. Grant of Patent License. Subject to the terms and conditions of
232
+ this License, each Contributor hereby grants to You a perpetual,
233
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
234
+ (except as stated in this section) patent license to make, have made,
235
+ use, offer to sell, sell, import, and otherwise transfer the Work,
236
+ where such license applies only to those patent claims licensable
237
+ by such Contributor that are necessarily infringed by their
238
+ Contribution(s) alone or by combination of their Contribution(s)
239
+ with the Work to which such Contribution(s) was submitted. If You
240
+ institute patent litigation against any entity (including a
241
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
242
+ or a Contribution incorporated within the Work constitutes direct
243
+ or contributory patent infringement, then any patent licenses
244
+ granted to You under this License for that Work shall terminate
245
+ as of the date such litigation is filed.
246
+
247
+ 4. Redistribution. You may reproduce and distribute copies of the
248
+ Work or Derivative Works thereof in any medium, with or without
249
+ modifications, and in Source or Object form, provided that You
250
+ meet the following conditions:
251
+
252
+ (a) You must give any other recipients of the Work or
253
+ Derivative Works a copy of this License; and
254
+
255
+ (b) You must cause any modified files to carry prominent notices
256
+ stating that You changed the files; and
257
+
258
+ (c) You must retain, in the Source form of any Derivative Works
259
+ that You distribute, all copyright, patent, trademark, and
260
+ attribution notices from the Source form of the Work,
261
+ excluding those notices that do not pertain to any part of
262
+ the Derivative Works; and
263
+
264
+ (d) If the Work includes a "NOTICE" text file as part of its
265
+ distribution, then any Derivative Works that You distribute must
266
+ include a readable copy of the attribution notices contained
267
+ within such NOTICE file, excluding those notices that do not
268
+ pertain to any part of the Derivative Works, in at least one
269
+ of the following places: within a NOTICE text file distributed
270
+ as part of the Derivative Works; within the Source form or
271
+ documentation, if provided along with the Derivative Works; or,
272
+ within a display generated by the Derivative Works, if and
273
+ wherever such third-party notices normally appear. The contents
274
+ of the NOTICE file are for informational purposes only and
275
+ do not modify the License. You may add Your own attribution
276
+ notices within Derivative Works that You distribute, alongside
277
+ or as an addendum to the NOTICE text from the Work, provided
278
+ that such additional attribution notices cannot be construed
279
+ as modifying the License.
280
+
281
+ You may add Your own copyright statement to Your modifications and
282
+ may provide additional or different license terms and conditions
283
+ for use, reproduction, or distribution of Your modifications, or
284
+ for any such Derivative Works as a whole, provided Your use,
285
+ reproduction, and distribution of the Work otherwise complies with
286
+ the conditions stated in this License.
287
+
288
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
289
+ any Contribution intentionally submitted for inclusion in the Work
290
+ by You to the Licensor shall be under the terms and conditions of
291
+ this License, without any additional terms or conditions.
292
+ Notwithstanding the above, nothing herein shall supersede or modify
293
+ the terms of any separate license agreement you may have executed
294
+ with Licensor regarding such Contributions.
295
+
296
+ 6. Trademarks. This License does not grant permission to use the trade
297
+ names, trademarks, service marks, or product names of the Licensor,
298
+ except as required for reasonable and customary use in describing the
299
+ origin of the Work and reproducing the content of the NOTICE file.
300
+
301
+ 7. Disclaimer of Warranty. Unless required by applicable law or
302
+ agreed to in writing, Licensor provides the Work (and each
303
+ Contributor provides its Contributions) on an "AS IS" BASIS,
304
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
305
+ implied, including, without limitation, any warranties or conditions
306
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
307
+ PARTICULAR PURPOSE. You are solely responsible for determining the
308
+ appropriateness of using or redistributing the Work and assume any
309
+ risks associated with Your exercise of permissions under this License.
310
+
311
+ 8. Limitation of Liability. In no event and under no legal theory,
312
+ whether in tort (including negligence), contract, or otherwise,
313
+ unless required by applicable law (such as deliberate and grossly
314
+ negligent acts) or agreed to in writing, shall any Contributor be
315
+ liable to You for damages, including any direct, indirect, special,
316
+ incidental, or consequential damages of any character arising as a
317
+ result of this License or out of the use or inability to use the
318
+ Work (including but not limited to damages for loss of goodwill,
319
+ work stoppage, computer failure or malfunction, or any and all
320
+ other commercial damages or losses), even if such Contributor
321
+ has been advised of the possibility of such damages.
322
+
323
+ 9. Accepting Warranty or Additional Liability. While redistributing
324
+ the Work or Derivative Works thereof, You may choose to offer,
325
+ and charge a fee for, acceptance of support, warranty, indemnity,
326
+ or other liability obligations and/or rights consistent with this
327
+ License. However, in accepting such obligations, You may act only
328
+ on Your own behalf and on Your sole responsibility, not on behalf
329
+ of any other Contributor, and only if You agree to indemnify,
330
+ defend, and hold each Contributor harmless for any liability
331
+ incurred by, or claims asserted against, such Contributor by reason
332
+ of your accepting any such warranty or additional liability.
333
+
334
+ END OF TERMS AND CONDITIONS
335
+
336
+ APPENDIX: How to apply the Apache License to your work.
337
+
338
+ To apply the Apache License to your work, attach the following
339
+ boilerplate notice, with the fields enclosed by brackets "[]"
340
+ replaced with your own identifying information. (Don't include
341
+ the brackets!) The text should be enclosed in the appropriate
342
+ comment syntax for the file format. We also recommend that a
343
+ file or class name and description of purpose be included on the
344
+ same "printed page" as the copyright notice for easier
345
+ identification within third-party archives.
346
+
347
+ Copyright [2023] jamsinclair
348
+
349
+ Licensed under the Apache License, Version 2.0 (the "License");
350
+ you may not use this file except in compliance with the License.
351
+ You may obtain a copy of the License at
352
+
353
+ http://www.apache.org/licenses/LICENSE-2.0
354
+
355
+ Unless required by applicable law or agreed to in writing, software
356
+ distributed under the License is distributed on an "AS IS" BASIS,
357
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
358
+ See the License for the specific language governing permissions and
359
+ limitations under the License.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "popmelt-core",
3
- "version": "0.37.1",
3
+ "version": "0.38.0",
4
4
  "description": "Local Popmelt context, canvas tools, and ambient turn capture for Claude Code.",
5
5
  "author": {
6
6
  "name": "Popmelt",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "popmelt-core",
3
- "version": "0.37.1",
3
+ "version": "0.38.0",
4
4
  "description": "Point out what you mean, talk through changes, and keep your AI on the same page.",
5
5
  "author": {
6
6
  "name": "Popmelt",
@@ -0,0 +1 @@
1
+ "use client";import{d as e}from"./chunk-OZBMHEOD.mjs";import{g as t,f as n,b as r}from"./chunk-ZSL57PQ7.mjs";import{a as o,b as a,c as i}from"./chunk-QXFBFKN6.mjs";import{c as s,f as l,d as p,e as d,a as c,b as u}from"./chunk-L356S4EY.mjs";import{a as h}from"./chunk-KL5ODVJA.mjs";import{c as m,a as g,b as f}from"./chunk-ELKVFX2O.mjs";import{n as v,m as b,k as x,b as y,c as w,l as k,j as C,i as S}from"./chunk-AWWUJO3N.mjs";import"./chunk-Q6N77LIS.mjs";import{c as E}from"./chunk-ZVDKW7TO.mjs";import"./chunk-FHCKFQBY.mjs";import"./chunk-APP5IYTE.mjs";import{a as I}from"./chunk-G2ZHJXHZ.mjs";import"./chunk-TMSGNHXH.mjs";import"./chunk-53SKVMWR.mjs";import"./chunk-RK6UROPO.mjs";import{l as P}from"./chunk-5IZHN3A7.mjs";import"./chunk-AOTDTBQO.mjs";import{h as O}from"./chunk-VXRRHXUP.mjs";import"./chunk-WP2SHSCG.mjs";import{v as T}from"./chunk-LH7HKUCK.mjs";import{a as N}from"./chunk-Q6C7ZA3H.mjs";import{b as j}from"./chunk-CK3CDA3L.mjs";import"./chunk-WJVRGXOS.mjs";import{b as A}from"./chunk-BEGAJYOY.mjs";import"./chunk-AGCS65LT.mjs";import{D as M,N as R,aa as z,Z as B,s as L,_ as J,F as H,G as V}from"./chunk-OA63PYHZ.mjs";import{a as D,c as K}from"./chunk-6RMM7JB6.mjs";import"./chunk-SUAHDXJZ.mjs";import"./chunk-YGP6PPOZ.mjs";import{useContext as X,useState as Y,useRef as W,useLayoutEffect as q,useMemo as U,useEffect as F,useCallback as Z}from"react";import{createPortal as G}from"react-dom";import{jsxs as $,Fragment as Q,jsx as _}from"react/jsx-runtime";import{createContext as ee,domToCanvas as te,destroyContext as ne}from"modern-screenshot";function re(e,t,n,r=!1){let[o,a]=Y({}),i=n?.backdrop,s=n?.style.color;return q(()=>{if(location.pathname!==e.pathname||r&&i)return void a({background:i,ink:s});let n="component"===t?y(e):void 0,o=n?.component??n?.element??T(e.selector,e.element);if(!o)return void a({background:i,ink:s});let l=o.ownerDocument.defaultView,p=()=>{let e=f(o)??i,t=l.getComputedStyle(o).color;a(n=>n.background===e&&n.ink===t?n:{background:e,ink:t})};p();let d=new MutationObserver(p),c=[o,...g(o)],u=e=>{["color","background-color"].includes(e.propertyName)&&e.target===e.currentTarget&&p()};for(let e of c)d.observe(e,{attributes:!0}),e.addEventListener("transitionend",u);let h=l.matchMedia("(prefers-color-scheme: dark)");return h.addEventListener("change",p),l.addEventListener("resize",p),()=>{d.disconnect();for(let e of c)e.removeEventListener("transitionend",u);h.removeEventListener("change",p),l.removeEventListener("resize",p)}},[e,t,i,s,r]),o}var oe=`\n.sp-card button { border: 0; cursor: pointer; font: inherit; }\n.sp-card {\n --sp-control-bg: light-dark(var(--popmelt-thread-soft, #f2f2f2), #363636);\n position: relative;\n align-self: stretch;\n min-width: 0;\n width: 100%;\n margin-top: 6px;\n border-radius: 12px;\n overflow: hidden;\n color: var(--popmelt-thread-primary, #222);\n font:\n 13px/1.38 'Popmelt Geist',\n system-ui,\n sans-serif;\n}\n.sp-card, .sp-workspace {\n color-scheme: light dark;\n background-color: var(--sp-page-background, var(--popmelt-thread-raised, light-dark(#fff, #181818)));\n background-image: radial-gradient(circle, var(--sp-page-dot, light-dark(#f2f2f2, #222222)) 1px, transparent 1.25px);\n background-size: 11px 11px;\n}\n:is(.sp-workspace[data-popmelt-theme='dark'], [data-popmelt-theme='dark'] .sp-card) {\n color-scheme: dark;\n}\n:is(.sp-workspace[data-popmelt-theme='light'], [data-popmelt-theme='light'] .sp-card) {\n color-scheme: light;\n}\n.sp-stage {\n position: relative;\n min-height: 185px;\n display: grid;\n /* The zoom viewport measures this track. Keep captured images and previous\n zoom measurements from increasing its intrinsic minimum width. */\n grid-template-columns: minmax(0, 1fr);\n place-items: center;\n padding: 0;\n}\n.sp-actions,\n.sp-zoom-actions {\n position: absolute;\n z-index: 2;\n top: 6px;\n display: flex;\n gap: 3px;\n opacity: 0;\n pointer-events: none;\n transition: opacity 120ms ease-out;\n}\n.sp-actions {\n right: 6px;\n}\n.sp-zoom-actions {\n left: 6px;\n}\n.sp-card:is(:hover, :has(:focus-visible)) :is(.sp-actions, .sp-zoom-actions),\n.sp-actions[data-preview-active='true'] {\n opacity: 1;\n pointer-events: auto;\n}\n.sp-zoom-actions [role='group'] {\n display: flex;\n gap: 2px;\n}\n.sp-card :is(.sp-actions, .sp-zoom-actions) button {\n color: var(--popmelt-thread-primary, #383838);\n background: var(--sp-control-bg);\n border-radius: 8px;\n width: 28px;\n height: 26px;\n display: grid;\n place-items: center;\n}\n.sp-card .sp-zoom-actions button {\n width: 26px;\n}\n.sp-card .sp-zoom-actions button:disabled {\n color: #aaa;\n cursor: default;\n}\n.sp-card .sp-actions button[aria-pressed='true'] {\n background: var(--sp-accent, #ed1014);\n color: white;\n}\n.sp-card button:focus-visible {\n outline: 2px solid var(--sp-accent, #ed1014);\n outline-offset: 2px;\n}\n.sp-card svg {\n width: 14px;\n height: 14px;\n}\n/* Thread text is selectable by default, including individual spans. */\n.sp-card footer, .sp-card footer * {\n -webkit-user-select: none !important;\n user-select: none !important;\n}\n.sp-card footer {\n font: 14px/1.5 ${D};\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 3px;\n position: absolute;\n inset: auto 0 0;\n z-index: 2;\n padding: 6px;\n pointer-events: none;\n}\n.sp-card .tag-option,\n.sp-card .pager button {\n padding: 3px;\n background: none;\n color: inherit;\n}\n.sp-card .tag-option {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n min-width: 0;\n text-align: left;\n}\n.sp-card .tag-option > span {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.sp-card .tag-option > svg {\n flex: none;\n opacity: 0;\n transition: opacity 120ms ease-out;\n}\n.sp-card .tag-option:is(:hover, :focus-visible) > svg {\n opacity: 1;\n}\n@media (hover: none), (max-width: 480px) {\n .sp-card .tag-option > svg {\n opacity: 1;\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .sp-card .tag-option > svg {\n transition: none;\n }\n}\n.sp-card .pager {\n display: flex;\n align-items: center;\n gap: 3px;\n color: var(--popmelt-thread-primary, #383838);\n white-space: nowrap;\n}\n.sp-card .pager-number {\n font-variant-numeric: tabular-nums;\n}\n.sp-card .pager button {\n width: 22px;\n height: 22px;\n display: grid;\n place-items: center;\n}\n.sp-card footer :is(.tag-option, .pager) {\n pointer-events: auto;\n touch-action: manipulation;\n}\n.sp-card footer .tag-option {\n padding: 0;\n}\n.sp-card .tag-option > span,\n.sp-card .pager {\n box-sizing: border-box;\n min-height: 26px;\n padding: 2px 8px;\n border-radius: 8px;\n background: var(--sp-control-bg);\n}\n.sp-card .tag-option > span {\n align-content: center;\n}\n.sp-card footer .pager {\n padding-inline: 2px;\n touch-action: pan-y pinch-zoom;\n}\n@media (prefers-reduced-motion: reduce) {\n .sp-actions,\n .sp-zoom-actions {\n transition: none;\n }\n}\n@media (hover: none), (max-width: 480px) {\n .sp-actions,\n .sp-zoom-actions {\n pointer-events: auto;\n opacity: 1;\n transition: none;\n }\n}\n\n.sp-expanded-placeholder, .sp-steer-frame { height: 260px; }\n.sp-steer-frame {\n position: relative;\n border: 0;\n display: block;\n width: 100%;\n border-radius: inherit;\n}\n\n/* An expanded card covers the annotation canvas. Its editor takes the free side of the thread. */\n/* Group the toolbar and its popovers above the editor, alongside the thread. */\n:is(body, [data-popmelt-root]):has(> .sp-workspace:not([hidden])) [data-popmelt-toolbar-layer] {\n position: relative;\n z-index: 10004;\n}\n/* Preserve the toolbar's geometry while the active preview covers its controls. */\n[data-popmelt-toolbar-layer][inert] { opacity: 0; }\n.sp-workspace {\n position: fixed;\n inset: 8px;\n overflow: clip;\n box-shadow: 0 0 0 100vmax light-dark(rgb(255 255 255 / 50%), rgb(0 0 0 / 50%));\n}\n.sp-workspace .sp-card {\n position: absolute;\n inset: 0 var(--sp-work-right, 0px) 0 var(--sp-work-left, 0px);\n width: auto;\n display: flex;\n flex-direction: column;\n margin: 0;\n border-radius: 0;\n background: transparent;\n}\n.sp-workspace .sp-stage {\n flex: 1;\n min-height: 0;\n}\n.sp-workspace .sp-steer-frame {\n position: absolute;\n inset: 0;\n height: 100%;\n}\n.sp-workspace :is(.sp-actions, .sp-zoom-actions) {\n top: 12px;\n opacity: 1;\n pointer-events: auto;\n}\n.sp-workspace .sp-actions { right: 12px; }\n.sp-workspace .sp-zoom-actions { left: 12px; }\n.sp-workspace .sp-card footer { padding: 12px; }\n.sp-card .sp-expanded-badge {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n border-radius: 8px;\n min-height: 26px;\n padding: 2px 8px;\n background: var(--sp-control-bg);\n color: inherit;\n}\n[data-popmelt-explore-canvas="right"] .sp-expanded-badge > svg { rotate: 180deg; }\n@media (max-width: 480px) {\n /* Keep the same mounted composer and card; the portal uses the space above them. */\n [data-devtools="thread-panel"][data-popmelt-explore-canvas] {\n top: auto !important;\n height: auto !important;\n padding: 0 !important;\n border: 0 !important;\n background: transparent !important;\n backdrop-filter: none !important;\n }\n [data-popmelt-explore-canvas] [data-popmelt-thread-shell] {\n overflow: visible !important;\n background: transparent !important;\n }\n [data-popmelt-explore-canvas] :is([data-popmelt-thread-header], [data-devtools="thread-panel-messages"], [data-queued-replies-area], [data-scroll-to-bottom]) {\n display: none !important;\n }\n .sp-workspace {\n inset: max(var(--popmelt-thread-visible-top, 8px), env(safe-area-inset-top))\n max(8px, env(safe-area-inset-right))\n calc(max(var(--popmelt-thread-visible-bottom, 8px), env(safe-area-inset-bottom)) + var(--sp-thread-height, 0px) + 6px)\n max(8px, env(safe-area-inset-left));\n }\n .sp-workspace .sp-card { inset: 0; }\n [data-popmelt-explore-canvas] .sp-expanded-badge > svg { rotate: 90deg; }\n}\n`;function ae({anchor:e,surfaceStyle:t,children:n}){let{visible:r}=X(c),o=W(null),[a,i]=Y(null);return q(()=>{i(e.current?.closest("[data-popmelt-root]")??document.body)},[e]),q(()=>{if(r&&a)return function(e){let t=e.createElement("style");return t.textContent=":root, body { overflow: hidden !important; overscroll-behavior: none !important; }",e.head.append(t),()=>t.remove()}(a.ownerDocument)},[a,r]),q(()=>{let t=o.current,n=e.current?.closest('[data-devtools="thread-panel"]');if(!t||!n||!r)return;n.dataset.popmeltExploreCanvas="left";let i=a?.querySelector("[data-popmelt-toolbar-layer]"),s=i?.querySelector("#devtools-toolbar"),l=()=>{let e=n.getBoundingClientRect();if(i&&s){let t=s.getBoundingClientRect(),n=e.left<t.right+1&&e.right>t.left-1&&e.top<t.bottom+1&&e.bottom>t.top-1;i.inert=N(window.innerWidth)||n}let r=t.getBoundingClientRect(),o=e.left-r.left>=r.right-e.right;n.dataset.popmeltExploreCanvas=o?"left":"right",t.style.setProperty("--sp-thread-height",`${e.height}px`),t.style.setProperty("--sp-work-left",o?"0px":`${Math.max(0,e.right-r.left)}px`),t.style.setProperty("--sp-work-right",o?`${Math.max(0,r.right-e.left)}px`:"0px"),t.style.borderRadius=getComputedStyle(n).borderRadius,t.dataset.popmeltTheme=n.dataset.popmeltTheme;for(let e of Array.from(n.style))e.startsWith("--popmelt-thread-")&&t.style.setProperty(e,n.style.getPropertyValue(e))};l();let p=new ResizeObserver(l);p.observe(n),s&&p.observe(s);let d=new MutationObserver(l);return d.observe(n,{attributes:!0,attributeFilter:["style","data-popmelt-theme"]}),s&&d.observe(s,{attributeFilter:["style"]}),window.addEventListener("resize",l),()=>{i&&(i.inert=!1),delete n.dataset.popmeltExploreCanvas,p.disconnect(),d.disconnect(),window.removeEventListener("resize",l)}},[e,a,r]),a?G(_("div",{hidden:!r,ref:o,className:"sp-workspace","data-popmelt-font":"sans",style:{...t,zIndex:10003},children:n}),a):null}function ie({tag:e,framing:t}){let n=W(null);return _("div",{"data-devtools":"preview-feedback-picker",style:{position:"absolute",inset:0,cursor:e?"crosshair":"default",userSelect:"none"},onPointerDown:e=>{n.current=e.isPrimary&&0===e.button?{id:e.pointerId,x:e.clientX,y:e.clientY,dragged:!1}:null},onPointerMove:e=>{let r=n.current;if(r?.id!==e.pointerId)return;let o=e.clientX-r.x,a=e.clientY-r.y;if(!r.dragged&&Math.hypot(o,a)<=8||(r.dragged=!0,r.x=e.clientX,r.y=e.clientY,"touch"!==e.pointerType||t.getScale()<=1))return;let{width:i,height:s}=e.currentTarget.getBoundingClientRect();if(!i||!s)return;let l=t.getView(i,s);t.setView(l.scale,l.x+o/i,l.y+a/s,i,s)},onPointerLeave:()=>{n.current=null},onPointerCancel:()=>{n.current=null},onPointerUp:t=>{let r=n.current;if(n.current=null,r?.id!==t.pointerId||r.dragged||Math.hypot(t.clientX-r.x,t.clientY-r.y)>8||!e)return;let o=t.currentTarget.parentElement?.querySelector(".sp-fit");if(!o)return;let a=O(t.clientX,t.clientY,{within:o})?.closest("[data-scratch-part]");a&&e(a.getAttribute("data-scratch-part"),S(a))}})}function se({capture:e,framing:t}){let n=W(null),[r,o]=Y(1);return q(()=>{let r=n.current,a=()=>{let n=Math.max(.01,Math.min(1,(r.clientWidth-36)/e.width,(r.clientHeight-36)/e.height));o(n),t.setFitScale(n)};a();let i=new ResizeObserver(a);return i.observe(r),()=>i.disconnect()},[e,t]),_("div",{className:"sp-steer-frame",ref:n,children:_(i,{interactive:!0,framing:t,overlay:_(ie,{framing:t}),children:_("div",{style:{display:"grid",placeItems:"center",width:"100%",height:"100%"},children:_("img",{alt:"Original at exploration time",src:e.still,draggable:!1,style:{width:e.width*r,height:e.height*r,maxWidth:"none"}})})})})}function le({original:e,bundles:t,target:n,theme:r,accent:o,framing:a,onEscape:i}){let[s,l]=Y(!1),{capture:p,runnable:c}=e,u=c&&t?.[c.fixture.bundle];return c&&!s&&"string"!=typeof u?u?_(d,{bundle:u,target:n,readOnly:!0,capture:p,theme:r,accent:o,framing:a,initial:[],onError:()=>l(!0),onEscape:i}):_("div",{className:"sp-steer-frame",role:"status",children:"Loading original…"}):p?.still?_(se,{capture:p,framing:a}):_("div",{className:"sp-steer-frame",role:"status",children:"Original unavailable for this round."})}function pe({frameUrl:e,theme:t,...n}){let[r,o]=Y(null);return q(()=>{r&&t&&(r.documentElement.style.colorScheme=t)},[r,t]),q(()=>{if(!r||!n.captureRef)return;let e=()=>{let e=r.querySelector(".sp-fit");return e?async function(e,t){let n=e.ownerDocument;await n.fonts.ready;let r=e.getBoundingClientRect(),o=e.offsetWidth,a=e.offsetHeight;if(!o||!a||!r.width)throw Error("The option is not ready to capture.");let i=r.width/o,s=Array.from(e.children,e=>e.getBoundingClientRect()).filter(e=>e.width&&e.height);s.length||s.push(r);let l,p=Math.max(0,(Math.min(r.right,...s.map(e=>e.left))-r.left)/i-12),d=Math.max(0,(Math.min(r.bottom,...s.map(e=>e.top))-r.top)/i-12),c=Math.min(o,(Math.max(r.left,...s.map(e=>e.right))-r.left)/i+12),u=Math.min(a,(Math.max(r.top,...s.map(e=>e.bottom))-r.top)/i+12),h=await ee(e,{width:o,height:a,scale:Math.min(2,1600/Math.max(o,a)),backgroundColor:t,timeout:2500,style:{transform:"none",position:"static",margin:"0"},onCloneEachNode:e=>{if(1!==e.nodeType)return;let t=e;(t.hasAttribute("data-tagged")||t.hasAttribute("data-badge-hover")||t.hasAttribute("data-scratch-part"))&&(t.style.outline="none"),t.removeAttribute("data-tagged"),t.removeAttribute("data-badge-hover")}});h.sandbox=n.createElement("iframe");try{l=await te(h)}finally{ne(h)}let m=n.createElement("canvas"),g=l.width/o;return m.width=Math.max(1,Math.ceil((c-p)*g)),m.height=Math.max(1,Math.ceil((u-d)*g)),m.getContext("2d").drawImage(l,-p*g,-d*g),new Promise((e,t)=>m.toBlob(n=>n?e(n):t(Error("Could not capture the reviewed option.")),"image/png"))}(e,n.captureBackground??"transparent"):Promise.reject(Error("The option is still loading."))},t=n.captureRef;return t.current=e,()=>{t.current===e&&(t.current=null)}},[r,n.captureRef,n.captureBackground]),$(Q,{children:[_("iframe",{className:"sp-steer-frame",style:{colorScheme:t},"aria-label":"Edit or comment on this option",src:e,srcDoc:e?void 0:h,onLoad:e=>{let t=e.currentTarget.contentDocument;t&&K(t),o(t)}}),r&&_(de,{doc:r,...n},n.editorKey)]})}function de({doc:e,...t}){let{toggle:n}=X(c),r=W(t),o=W(t);o.current=t;let a=W(void 0);q(()=>{let t=e.defaultView;if(!t)return;let{node:i,initial:s,target:l,accentColor:p,framing:d}=r.current,c=!0,u=s;a.current=t.startScratchSteer?.(i,l,p,d,e=>{if(!c)return;let t=C(s,e);JSON.stringify(t)!==JSON.stringify(u)&&(u=t,o.current.onChange(t))},e=>{c&&o.current.onTag(e)},e=>{c&&o.current.onPreview(e)},n);let h=e=>{"Escape"!==e.key||!o.current.onEscapeWorkspace||e.target?.closest?.('input, textarea, [contenteditable="true"]')||(e.preventDefault(),e.stopImmediatePropagation(),o.current.onEscapeWorkspace())};return t.addEventListener("keydown",h,!0),()=>{c=!1,a.current=void 0,o.current.onPreview(null),t.removeEventListener("keydown",h,!0)}},[e,n]);let i=E(),[s,l]=Y();q(()=>{let t=e.defaultView?.frameElement;if(t instanceof HTMLIFrameElement)return u(t,l,()=>{e.documentElement.setAttribute("data-preview-control-hovered","")})},[e]);let{selectedPart:p,hoveredPart:d,focusRequest:h}=t;return q(()=>{a.current?.({feedbackOnly:i,selectedPart:p,hoveredPart:d,focusRequest:h,controlBounds:s})},[e,n,p,d,h,s,i]),null}function ce(e){!e||e.getRootNode().activeElement?.closest("[data-popmelt-thread-composer]")||e.querySelector("[data-expand-option]")?.focus({preventScroll:!0})}function ue({batch:t,frameUrl:n,bundles:r,canApply:i=!0,frozenVersion:s,framing:l,theme:d,accentColor:c,selection:u,preview:h,setTag:g,onTogglePreview:f,onBrowse:v,edits:b,revisions:x,index:y,hoveredTarget:w,focusRequest:k,onPreviewStyle:C,onFixtureCanvas:S,onSteer:E,onApply:I,busy:O,expanded:T,onExpand:N}){let A=W(null),[J,H]=Y(""),[V,D]=Y(!1),K=W(null),X=W(null),U=Z(e=>{X.current=e,ce(e)},[]),F=W(T);q(()=>{F.current&&!T&&ce(K.current),F.current=T},[T]),q(()=>{if(k?.batchId!==t.id||k.option!==y)return;let e=T?X.current:K.current,n=e?.closest('[data-devtools="thread-panel-messages"]');if(!e||!n)return;let r=e.getBoundingClientRect(),o=n.getBoundingClientRect();r.top>=o.top&&r.bottom<=o.bottom||n.scrollBy({top:r.top-o.top-Math.max(0,(n.clientHeight-r.height)/2),behavior:window.matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":"smooth"})},[t.id,y,k,T]);let G=JSON.stringify([t.id,y,s??x?.[y]??0]),[ee]=Y(()=>l??o(null)),te=t.options.length,ne=-1===y?t.original:void 0,ie=t.options[Math.max(0,y)],{background:se,ink:de}=re(t.target,ne?.capture?.scope??("fixture"in ie?ie.previewScope:void 0),t.original?.capture,!!ne),ue=se?m(se):void 0,me=ue?.theme??d,ge={"--sp-page-background":se,"--sp-accent":c,"--sp-page-dot":ue?.dot,backgroundImage:ne?"none":void 0},fe={batchId:t.id,option:y,path:[]},ve=h?.showVariant&&h.target.batchId===t.id&&h.target.option===y;let be="fixture"in ie?r?.[ie.fixture.bundle]:void 0,xe=_(he,{title:ne?"Original":ie.title,index:ne?-1:y,hasOriginal:!!t.original,optionCount:te,accentColor:c,canTag:i,onTag:()=>g(fe),browseBy:function(e){let n=t.original?-1:0,r=te-n,o=n+(y-n+e+r)%r;H(""),v({...fe,option:o})}}),ye=$("div",{className:"sp-stage",style:{cursor:P(c)},children:[_("div",{className:"sp-zoom-actions",children:_(a,{framing:ee})}),$("div",{className:"sp-actions","data-preview-active":!!h,children:[!ne&&ve&&i&&_(j,{type:"button","aria-label":"Apply this option in code",disabled:O||V,onClick:async()=>{H(""),D(!0);try{if(!A.current)throw Error("The option is still loading. Try again in a moment.");let e=await A.current();await I(fe,e)}catch(e){H(e instanceof Error?e.message:"Could not apply this option.")}finally{D(!1)}},children:_(M,{})}),!s&&(!ne||!!h)&&_(j,{type:"button","aria-pressed":!!h,hint:!T&&h?"Turn off page preview":"Preview on page","aria-label":"Preview on page",disabled:"fixture"in ie&&(!be||"string"==typeof be),onClick:()=>f(fe),children:_(R,{})}),_(j,{type:"button","data-expand-option":"","aria-label":T?"Collapse preview":"Expand preview","aria-expanded":T,onClick:()=>N(!T),children:_(T?z:B,{})})]}),ne?_(le,{original:ne,target:t.target,bundles:r,framing:ee,theme:me,accent:c,onEscape:T?()=>N(!1):void 0}):"fixture"in ie?_(p,{captureRef:A,captureBackground:se??void 0,frameKey:G,frozenParent:!!s,readOnly:!!s,capture:s?t.original?.capture:void 0,bundle:be,previewScope:ie.previewScope,target:t.target,pageInk:se?de:void 0,framing:ee,theme:me,accent:c,initial:b.filter(e=>e.batchId===t.id&&e.option===y),onCanvas:e=>S?.(ie.fixture.bundle,e),onEscape:T?()=>N(!1):void 0,selected:u?.batchId===t.id&&u.option===y?u.fixturePart:void 0,onTag:(e,t)=>g({...fe,fixturePart:e,fixturePartLabel:t}),onChange:e=>E(y,e),onPreview:e=>C(y,e)}):_(pe,{captureRef:A,captureBackground:se??void 0,editorKey:G,readOnly:!!s,framing:ee,onEscapeWorkspace:T?()=>N(!1):void 0,frameUrl:n,target:t.target,node:ie.root,theme:me,accentColor:c,initial:b.filter(e=>e.batchId===t.id&&e.option===y),onPreview:e=>C(y,e),hoveredPart:w?.batchId===t.id&&w.option===y?w.part:void 0,focusRequest:k?.batchId===t.id&&k.option===y?k:void 0,selectedPart:u?.batchId===t.id&&u.option===y?u.path.join(".")+(u.field?"/label":""):void 0,onChange:e=>E(y,e),onTag:e=>{let[t,n]=e.split("/");g({...fe,path:t?t.split(".").map(Number):[],field:"label"===n?"label":void 0})}}),J&&_("span",{role:"alert",children:J}),xe]});return $(Q,{children:[$("section",{ref:K,"data-explore-batch":t.id,"aria-label":"Explore options",className:"sp-card",style:ge,"data-popmelt-tooltip-group":"",children:[_("style",{children:oe}),T?$("div",{className:"sp-stage sp-expanded-placeholder",children:[$(j,{type:"button",className:"sp-expanded-badge",hint:"Collapse preview","aria-label":"Preview expanded. Collapse preview","aria-expanded":!0,onClick:()=>N(!1),children:[_(L,{"aria-hidden":"true"}),"Preview expanded"]}),xe]}):ye]}),!ne&&"fixture"in ie&&ie.rationale&&_(e,{text:ie.rationale}),T&&_(ae,{anchor:K,surfaceStyle:ge,children:_("section",{ref:U,"aria-label":"Expanded explore options",className:"sp-card","data-popmelt-tooltip-group":"","data-popmelt-tooltip-boundary":!0,children:ye})})]})}function he({title:e,index:t,optionCount:n,hasOriginal:r,accentColor:o,onTag:a,canTag:i,browseBy:s}){let l=W(null),p=W(null);return $("footer",{children:[t<0?_("span",{className:"tag-option",children:_("span",{children:e})}):$(j,{above:!0,className:"tag-option",disabled:!i,hint:"Add to chat",anchorRef:l,"aria-label":`Add ${e} to chat`,onClick:a,children:[_("span",{children:e}),_(J,{ref:l,"aria-hidden":"true",color:o})]}),(r||n>1)&&$("div",{className:"pager",onTouchStart:e=>{let t=e.touches[0];p.current=1===e.touches.length?{id:t.identifier,x:t.clientX,y:t.clientY}:null},onTouchCancel:()=>{p.current=null},onTouchEnd:e=>{let t=p.current;p.current=null;let n=e.changedTouches[0];if(!t||!n||n.identifier!==t.id||e.touches.length)return;let r=n.clientX-t.x,o=n.clientY-t.y;Math.abs(r)<24||Math.abs(r)<1.3*Math.abs(o)||(e.preventDefault(),s(r>0?1:-1))},children:[_("button",{type:"button","aria-label":"Previous option",onClick:()=>s(-1),children:_(H,{})}),$("span",{"aria-live":"polite",children:[_("span",{className:"pager-number",children:t+1})," of"," ",_("span",{className:"pager-number",children:n})]}),_("button",{type:"button","aria-label":"Next option",onClick:()=>s(1),children:_(V,{})})]})]})}function me(e,t,n){return`popmelt-explore-draft:${e}:${t}:${n}`}function ge(e,t,n,r,o){try{let a=me(e,t,n);void 0!==o?window.localStorage.setItem(a,JSON.stringify({revision:o,edits:r})):r.length?window.localStorage.setItem(a,JSON.stringify(r)):window.localStorage.removeItem(a)}catch{}}function fe(e,t,n,r){try{let o=me(e,t,n),a=window.localStorage.getItem(o);if(!a)return;let i=JSON.parse(a),s=Array.isArray(i)?{revision:0,edits:i}:i;s.revision===r.revision&&JSON.stringify(s.edits.map(k))===JSON.stringify(r.edits)&&window.localStorage.removeItem(o)}catch{}}var ve={edits:[]};function be(e,t,n,r,o){let[a]=Y(()=>function(e,t){let n={};return t.options.forEach((r,o)=>{try{let r=window.localStorage.getItem(me(e,t.id,o));if(!r)return;let a=JSON.parse(r),{revision:i,edits:s}=Array.isArray(a)?{revision:0,edits:a}:a;if(!Number.isSafeInteger(i)||i<0||!Array.isArray(s))return;let l=s.map(k);if(l.some(e=>e.batchId!==t.id||e.option!==o))return;b({messages:[{batch:t}]},x(l)),n[o]={revision:i,edits:l}}catch{}}),n}(e,t)),[i,s]=Y(()=>({...n,...a})),l=W(i),p=W({...n}),d=W({...a}),c=W(new Set),u=W(new Map),[h,m]=Y({}),[g,f]=Y(""),v=o&&void 0!==n;function y(e,t,n){let r=l.current[e]??ve;l.current={...l.current,[e]:t},JSON.stringify(r.edits)!==JSON.stringify(t.edits)&&(s(l.current),n&&m(t=>({...t,[e]:(t[e]??0)+1})))}async function w(n){if(v&&!c.current.has(n)){c.current.add(n);try{for(;d.current[n];){let o=d.current[n],a=await A(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({batchId:t.id,option:n,...o})});if(!a.ok&&409!==a.status)throw Error();let{draft:i}=await a.json();if(!i||!Number.isSafeInteger(i.revision)||!Array.isArray(i.edits))throw Error();i.revision>=(p.current[n]?.revision??0)&&(p.current[n]=i);let s=d.current[n];409===a.status||s===o?(delete d.current[n],fe(e,t.id,n,s),y(n,p.current[n],!0),f(409===a.status?"This option changed on another device. Its latest saved edits are shown.":"")):(s.revision=i.revision,ge(e,t.id,n,s.edits,s.revision))}}catch{f("Couldn’t sync option edits to this project.")}finally{c.current.delete(n)}}}let C=()=>Object.keys(d.current).forEach(e=>{w(Number(e))}),S=W(C);return q(()=>{S.current=C}),q(()=>{if(n)for(let[e,t]of Object.entries(n)){let n=Number(e);t.revision<(p.current[n]?.revision??0)||(p.current[n]=t,d.current[n]||y(n,t,!0))}},[n]),F(()=>{if(!v)return;let e=()=>S.current();e(),window.addEventListener("online",e);let t=u.current;return()=>{window.removeEventListener("online",e);for(let e of t.values())clearTimeout(e);t.clear(),e()}},[v]),{edits:U(()=>Object.values(i).flatMap(e=>e.edits),[i]),save:function(n,r){let o=d.current[n]?.revision??p.current[n]?.revision??0,a={revision:o,edits:r.map(k)};JSON.stringify(l.current[n]?.edits??[])!==JSON.stringify(a.edits)&&(d.current[n]=a,ge(e,t.id,n,a.edits,o),y(n,a,!1),v&&(clearTimeout(u.current.get(n)),u.current.set(n,setTimeout(()=>{u.current.delete(n),w(n)},220))))},revisions:h,failure:g,retry:C,unsynced:!!Object.keys(d.current).length}}function xe({batch:e,draftScope:a,threadId:i,sharedDrafts:p,bridgeUrl:d,theme:c,accentColor:u,active:h,hidden:m,revealOnPage:g,activate:f,expanded:k,onExpand:C,canReply:S,submit:E,selection:P,onAttach:O,focusRequest:T,workspaceRef:N,followSource:j}){let A=s(d,v(e)),M=X(I),R=M?.preview?.batchId===e.id&&M.preview.threadId===i?M.preview:null,z=M?!!R?.enabled:h,[B,L]=Y(()=>R?.index??0),J=W(null);q(()=>{J.current!==T&&(J.current=T,T&&T.batchId===e.id&&e.options[T.option]&&L(T.option))},[T,e.id,e.options]);let H=U(()=>T?{...T,part:""}:null,[T]),V=be(a,e,p,d+"/thread/"+encodeURIComponent(i)+"/explore-draft",S),[D,K]=Y(),F=T!==D&&T?.option===B?T.snapshot:void 0,Z=F?.edits??V.edits,[G]=Y(()=>o(null)),ee=U(()=>k&&!m&&!F&&B>=0?{batchId:e.id,option:B}:null,[k,m,F,e.id,B]),[te,ne]=Y(R?.targets??null),[re,oe]=Y(()=>R&&"fixture"in R.option?{[R.option.fixture.bundle]:R.hasCanvas}:{}),[ae,ie]=Y(""),[se,le]=Y(null),pe=U(()=>b({messages:[{batch:e}]},x(Z)).messages[0].batch,[e,Z]);q(()=>{if(!ee)return;let e={source:ee,framing:G,reference:()=>n(pe,{...ee,path:[]},Z)};return N.current=e,()=>{N.current===e&&(N.current=null)}},[N,ee,G,pe,Z]),q(()=>{let t=N.current;if(!t||t.source!==j)return;let n=e.options.findIndex((n,r)=>{let o=e.parents?.[r];return o?.batchId===t.source.batchId&&o.option===t.source.option&&(!("fixture"in n)||"object"==typeof A[n.fixture.bundle])});n<0||(G.restore(t.framing.snapshot()),L(n),C(!0))},[e,A,j,G,C,N]);let de=pe.options[Math.max(0,B)],ce=e=>"fixture"in de?w(e,de.previewScope,!!re[de.fixture.bundle]):e.element,he=B>=0&&te&&ce(te),me="fixture"in de&&"component"===de.previewScope?"Core could not locate a single root for this component on the page. You can still review the option here.":"Open the annotated page with its target visible to preview this option.",ge="fixture"in de?A[de.fixture.bundle]??(R&&"fixture"in R.option&&R.option.fixture.bundle===de.fixture.bundle?R.bundle:void 0):void 0,fe=U(()=>{let t=x(Z)[e.id]?.[B]??{},n={...t};if(se?.option===B)for(let[e,r]of Object.entries(se.parts))n[e]={...t[e],...r};return n},[Z,e.id,B,se]),ve="fixture"in de&&!!re[de.fixture.bundle],xe=U(()=>te?{threadId:i,batchId:e.id,index:B,enabled:!0,target:e.target,option:de,targets:te,hasCanvas:ve,bundle:"string"==typeof ge?void 0:ge,parts:fe,theme:c,accentColor:u,revealOnPage:g}:null,[i,e.id,e.target,B,de,te,ve,ge,fe,c,u,g]),ye=!!R,we=M?.setPreview;q(()=>{F||!ye||!xe||!we||we(t=>t?.batchId===e.id&&t.threadId===i?{...xe,enabled:t.enabled,suspended:t.suspended}:t)},[F,ye,xe,we,e.id,i]);let ke=()=>{we?.(t=>t?.batchId===e.id&&t.threadId===i?{...t,enabled:!1}:t),f(!1)},Ce=z?{target:{batchId:e.id,option:B,path:[]},showVariant:B>=0}:null,Se=e.parents?.[B];return $(Q,{children:[_(ue,{batch:pe,framing:G,bundles:A,index:B,edits:Z,theme:c,accentColor:u,selection:P,preview:Ce,expanded:k&&!m,onExpand:C,revisions:V.revisions,focusRequest:H,hoveredTarget:null,busy:!1,canApply:S&&!F,frozenVersion:F?T?.returnTo:void 0,onTogglePreview:()=>{if(ie(""),Ce&&!k)return void ke();let t=y(e.target),n=location.pathname===e.target.pathname&&ce(t);n&&n.parentElement&&!n.matches("body,html")&&!n.closest("[data-devtools]")?(ne(t),we?.({threadId:i,batchId:e.id,index:B,enabled:!0,target:e.target,option:de,targets:t,hasCanvas:ve,bundle:"string"==typeof ge?void 0:ge,parts:fe,theme:c,accentColor:u,revealOnPage:g}),C(!1),f(!0)):ie(me)},onBrowse:e=>{K(T),L(e.option),le(null)},onFixtureCanvas:(e,t)=>oe(n=>n[e]===t?n:{...n,[e]:t}),onPreviewStyle:(e,t)=>le(n=>t?{option:e,parts:t}:n?.option===e?null:n),onSteer:(t,n)=>{if(F)return;let r=n.map(n=>({...n,batchId:e.id,option:t}));V.save(t,r)},setTag:e=>{S&&!F&&O(n(pe,e,Z))},onApply:async(e,n)=>{let{text:r,meta:o}=t(pe,e.option,Z);if(!await E(r,n?{...o,exploreOption:{...o.exploreOption,selection:{...o.exploreOption.selection,reviewedImage:{replyImageIndex:0,capturedAt:Date.now(),description:"The attached image shows this reviewed option with its saved edits. Use it as the visual target to apply; the original annotation screenshot is earlier context."}}}}:o,n?[n]:void 0))throw Error("This thread cannot send the apply request.");ke(),C(!1)}}),F&&T?.returnTo?$("span",{children:["Parent version ·"," ",_(r,{reference:T.returnTo,children:"Back to iteration"})]}):Se?$("span",{children:["Based on"," ",_(r,{reference:{...Se,snapshot:Se,returnTo:{batchId:e.id,option:B,title:de.title}},showVersion:!0})]}):null,V.failure&&$("span",{role:"alert",children:[V.failure," ",V.unsynced&&_("button",{type:"button",onClick:V.retry,children:"Retry"})]}),(ae||z&&B>=0&&!m&&te&&!he)&&_("span",{role:"alert",children:ae||me}),!M&&!F&&z&&!m&&xe&&_(l,{preview:xe})]})}export{xe as ExploreAttachment};
@@ -1 +1 @@
1
- "use client";export{f as PagePreviewLayer}from"./chunk-WF3YGZPI.mjs";import"./chunk-OIKFQ2FV.mjs";import"./chunk-PWQB3FIW.mjs";import"./chunk-Q6N77LIS.mjs";import"./chunk-ZVDKW7TO.mjs";import"./chunk-FHCKFQBY.mjs";import"./chunk-APP5IYTE.mjs";import"./chunk-TMSGNHXH.mjs";import"./chunk-53SKVMWR.mjs";import"./chunk-5IZHN3A7.mjs";import"./chunk-AOTDTBQO.mjs";import"./chunk-WP2SHSCG.mjs";import"./chunk-LH7HKUCK.mjs";import"./chunk-Q6C7ZA3H.mjs";import"./chunk-NI77Y3WC.mjs";import"./chunk-FON4QY7P.mjs";import"./chunk-AGCS65LT.mjs";import"./chunk-SUAHDXJZ.mjs";
1
+ "use client";export{f as PagePreviewLayer}from"./chunk-L356S4EY.mjs";import"./chunk-KL5ODVJA.mjs";import"./chunk-AWWUJO3N.mjs";import"./chunk-Q6N77LIS.mjs";import"./chunk-ZVDKW7TO.mjs";import"./chunk-FHCKFQBY.mjs";import"./chunk-APP5IYTE.mjs";import"./chunk-TMSGNHXH.mjs";import"./chunk-53SKVMWR.mjs";import"./chunk-5IZHN3A7.mjs";import"./chunk-AOTDTBQO.mjs";import"./chunk-WP2SHSCG.mjs";import"./chunk-LH7HKUCK.mjs";import"./chunk-Q6C7ZA3H.mjs";import"./chunk-WJVRGXOS.mjs";import"./chunk-BEGAJYOY.mjs";import"./chunk-AGCS65LT.mjs";import"./chunk-SUAHDXJZ.mjs";import"./chunk-YGP6PPOZ.mjs";
@@ -0,0 +1 @@
1
+ "use client";import{d as t,b as e,c as o,a as r}from"./chunk-GTVTUWGH.mjs";import"./chunk-SKM4ZXV5.mjs";import"./chunk-TXL2CR66.mjs";import{f as i}from"./chunk-ZSTKAPV5.mjs";import"./chunk-ZHXTB5IN.mjs";import"./chunk-FYURSPM3.mjs";import"./chunk-43BZCDGL.mjs";import"./chunk-PH2MLB3T.mjs";import"./chunk-ZVDKW7TO.mjs";import"./chunk-XTOCFTVW.mjs";import"./chunk-KHDXOXYF.mjs";import"./chunk-SOGN7S54.mjs";import"./chunk-BJUSVIDN.mjs";import"./chunk-WNOLXY3Y.mjs";import{a as n}from"./chunk-JAMYVQFC.mjs";import{i as a,Y as s}from"./chunk-G6BN5TAZ.mjs";import"./chunk-B3RA4XAR.mjs";import"./chunk-DBCBG5J6.mjs";import"./chunk-G2ZHJXHZ.mjs";import"./chunk-TMSGNHXH.mjs";import"./chunk-53SKVMWR.mjs";import"./chunk-3LZQLRZ2.mjs";import"./chunk-RJWFSAKE.mjs";import"./chunk-P2WAXWAZ.mjs";import"./chunk-2F2BVGFH.mjs";import"./chunk-RWZ7SVMO.mjs";import"./chunk-RK6UROPO.mjs";import"./chunk-5IZHN3A7.mjs";import"./chunk-AOTDTBQO.mjs";import"./chunk-HAZXZ5TU.mjs";import"./chunk-TVIKC33M.mjs";import"./chunk-25EXQOPI.mjs";import"./chunk-VXRRHXUP.mjs";import"./chunk-WP2SHSCG.mjs";import{e as c,g as l,f as p}from"./chunk-AAMUU2QA.mjs";import"./chunk-LH7HKUCK.mjs";import{a as m}from"./chunk-3DUTQ6GY.mjs";import{b as h,f as u,c as d,d as f}from"./chunk-3VOEPWRL.mjs";import{o as j}from"./chunk-X56HNVHF.mjs";import"./chunk-X6I6KQDG.mjs";import"./chunk-ATLUO4G7.mjs";import"./chunk-JJRKR4X3.mjs";import"./chunk-C2ZSNUXQ.mjs";import"./chunk-TEXVTTWA.mjs";import"./chunk-Q6C7ZA3H.mjs";import"./chunk-EILBHZDX.mjs";import"./chunk-XJJDBMZI.mjs";import"./chunk-OREALBUO.mjs";import"./chunk-B4DYUYX4.mjs";import"./chunk-CK3CDA3L.mjs";import{c as k,a as g}from"./chunk-WJVRGXOS.mjs";import"./chunk-BEGAJYOY.mjs";import"./chunk-AGCS65LT.mjs";import{U as w}from"./chunk-OA63PYHZ.mjs";import"./chunk-6RMM7JB6.mjs";import{b as y}from"./chunk-SUAHDXJZ.mjs";import"./chunk-PRPXMDZ7.mjs";import"./chunk-A4GARXVQ.mjs";import"./chunk-YGP6PPOZ.mjs";import{useState as S,useSyncExternalStore as v,useEffect as I}from"react";import{jsx as A,jsxs as P}from"react/jsx-runtime";function O(t,i){let n,a={phase:"starting"},m=0,j=!1,k=!1,g=0,w=new Set,S=`popmelt-participant:${t.projectId}`,v=new h(t.url,t.projectId),I=t=>{if(!k){a=t;for(let t of w)t()}},A=()=>history.state?.popmeltGuestEntry===t.projectId,P=e=>history.replaceState({...history.state,popmeltGuestEntry:t.projectId},"",e),O=t=>fetch("/__popmelt/host",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(t),redirect:"error"}),H=async(e={},o=!1,r)=>{if(y(t.url))return null;let i=await O(e);if(403===i.status){let e=i.headers.get("X-Popmelt-Host-Origin"),n=i.headers.get("X-Popmelt-Session"),a=new URL(location.href);if(!o||!n||window.top!==window||!["localhost","127.0.0.1","[::1]"].includes(a.hostname)||a.pathname.startsWith("/__popmelt/")||a.searchParams.has("__popmelt_code_preview")||a.hash.includes("popmelt-")||A())return null;let s=localStorage.getItem(`popmelt-admission:${t.projectId}`);if(s)try{if(JSON.parse(s)?.receipt)return null}catch{return null}if(e&&function(t,e){try{let o=new URL(t),r=new URL(e),i=["localhost","127.0.0.1","[::1]"];return o.origin===t&&r.origin===e&&t!==e&&["http:","https:"].includes(o.protocol)&&o.protocol===r.protocol&&o.port===r.port&&i.includes(o.hostname)&&i.includes(r.hostname)}catch{return!1}}(location.origin,e)){let t=await fetch(e+"/__popmelt/host",{method:"HEAD",credentials:"omit",redirect:"error",referrerPolicy:"no-referrer",signal:AbortSignal.timeout(2e3)}).catch(()=>null);if(!k&&204===t?.status&&t.headers.get("X-Popmelt-Session")===n)throw a.host=new URL(e).host,location.replace(a.href),X;return null}let c=i.headers.get("X-Popmelt-Local-Port");if(!c||!/^[1-9]\d{0,4}$/.test(c)||Number(c)>65535)return null;let l=await fetch("http://127.0.0.1:"+c+"/",{method:"POST",headers:{"X-Popmelt-Session":n},credentials:"omit",cache:"no-store",redirect:"error",referrerPolicy:"no-referrer",signal:AbortSignal.timeout(6500)}).catch(()=>null);if(!l?.ok||k)return null;let p=await l.json().catch(()=>null);if("string"!=typeof p?.proof||(i=await O({localProof:p.proof,previousId:r}),403===i.status))return null}if(!i.ok)throw new Error(`Host entry unavailable (${i.status}).`);let n=`popmelt-before-participants:${t.projectId}`;return null===localStorage.getItem(n)&&localStorage.setItem(n,JSON.stringify(Object.fromEntries(Object.values(s(t.projectId)).map(t=>[t,localStorage.getItem(t)])))),await i.json()},X=Symbol("navigating"),R=async(a,s=g)=>{if(k||s!==g)return;let m=await r({bridgeUrl:t.url,projectId:t.projectId,credential:a,runtimeStorage:sessionStorage,observedSource:{sourceId:t.projectId,revision:t.revision},loadOwnSource:i,prepareApplication:t.planeApps?async r=>{if(k||s!==g)throw X;let i=c(location.pathname);if(r.author.id===a.participantId&&"host"===r.author.relationship&&!y(t.url)){if("/"!==i){let t=new URL(location.href);throw t.pathname=p(t.pathname),location.replace(t.href),X}return("/"===r.ownWorkspace?.basePath?r.ownWorkspace.revision:void 0)??r.draft.source?.revision??t.revision}let n=await e(a,a.participantId,void 0,location.pathname);if(k||s!==g)throw X;let m=o(n.application);if(t.appVersion??(t.appVersion=n.application.version),m!==l(location.pathname)||t.appVersion&&t.appVersion!==n.application.version)throw localStorage.setItem(S,JSON.stringify(a)),location.replace(m+location.search+location.hash),X;return n.application.basis??t.revision}:void 0}).catch(t=>{if(t!==X)throw t});if(m){if(k||s!==g)return void m.dispose();try{localStorage.setItem(S,JSON.stringify(a))}catch(t){throw m.dispose(),t}if(n?.dispose(),A()){let t={...history.state};delete t.popmeltGuestEntry,history.replaceState(t,"")}n=m,I({phase:"connected",connection:m}),H({credential:a}).catch(()=>{})}},b=()=>{P(location.href),g++,n?.dispose(),n=void 0,function(t,e){t.removeItem(`popmelt-participant:${e}`);let o,r=`popmelt-admission:${e}`;try{o=JSON.parse(t.getItem(r)??"null")}catch{return void t.removeItem(r)}o&&"object"==typeof o&&t.setItem(r,JSON.stringify({name:o.name,colorIdentity:o.colorIdentity??o.receipt}))}(localStorage,t.projectId),I({phase:"entry",invitation:null})};return{client:v,getSnapshot:()=>a,subscribe:t=>(w.add(t),()=>{w.delete(t)}),retain(){if(k)throw new Error("Participant lifecycle is disposed");m++,j||(j=!0,(async()=>{let t=u(location.href),e=new URL(t.cleanUrl),o=new URLSearchParams(e.hash.slice(1)),r=o.get("popmelt-host");o.delete("popmelt-host"),r&&(e.hash=o.toString()),t.token?P(e.href):e.href!==location.href&&history.replaceState(history.state,"",e);let i=null;if(r){if(i=await H({token:r}),!i&&!t.token&&(i=await H({},!0)),!i)throw new Error("Host entry expired. Use the current private host link.")}else if(!t.token&&!A()){try{i=JSON.parse(localStorage.getItem(S)??"null")}catch{}i??(i=await H({},!0))}if(k)return;if(!i)return void I({phase:"entry",invitation:t.token??null});let n=g;for(let e=1;!k&&n===g;e++)try{return void await R(i,n)}catch(o){if(k||n!==g)return;if(d(o)){I({phase:"error",message:o.message}),await new Promise(t=>setTimeout(t,f(e)));continue}if("access_removed"===o.code)return void b();if(401!==o.status)throw o;let a=await H({},!r&&!t.token,i.participantId);return void(a?await R(a):b())}})().catch(t=>{t!==X&&I({phase:"error",message:t.message})}));let t=!1;return()=>{t||(t=!0,m--,queueMicrotask(()=>{m||k||(k=!0,g++,n?.dispose(),n=void 0,w.clear())}))}},removed:b,async join(e,o){if("entry"!==a.phase||!a.invitation||k)throw new Error("No active invitation");if(!o)throw new Error("Peer identity is not ready");let r=g,i=await v.joinOrRequestAdmission(a.invitation,e,o);if(!k&&r===g){if("admission"in i)return localStorage.setItem(`popmelt-admission:${t.projectId}`,JSON.stringify({name:i.admission.name,receipt:o,colorIdentity:o})),void I({phase:"entry",invitation:null});await R(i.joined.credential,r)}},admit:t=>R(t)}}function H({config:r,loadOwnSource:s,children:p}){let[h]=S(()=>O(r,s)),u=a(),d=v(h.subscribe,h.getSnapshot,h.getSnapshot);I(()=>h.retain(),[h]);let[f,H,X]=k(),R="connected"===d.phase?d.connection:null;if(I(()=>{if(!R||!r.planeApps)return;let t,i=new AbortController,n=R.isHost&&!y(r.url)&&"/"===c(location.pathname),a=n?void 0:r.appVersion,s=async()=>{try{let t=await e(R.credential,R.credential.participantId,i.signal,location.pathname);if(n&&"/"!==t.application.basePath)throw new Error("Host checkout unavailable");let s=o(t.application);if(a??(a=t.application.version),!i.signal.aborted&&(s!==l(location.pathname)||t.application.version!==a)){if(R.isHost&&!y(r.url)){let t=await fetch(s+location.search,{method:"HEAD",headers:{Accept:"text/html"},mode:"same-origin",cache:"no-store",signal:i.signal});if(!t.ok||!t.headers.get("content-type")?.includes("text/html")||l(new URL(t.url).pathname)!==s)throw new Error("Host plane document unavailable")}return await R.state.flush(),void(i.signal.aborted||(s===l(location.pathname)?location.reload():location.replace(s+location.search+location.hash)))}}catch{}i.signal.aborted||(t=setTimeout(s,1500))};return s(),()=>{i.abort(),clearTimeout(t)}},[r.planeApps,r.appVersion,r.url,R,u]),R)return A(t,{connection:R,codePreviewUrl:location.href,planeApps:r.planeApps,onAccessRemoved:h.removed,children:p});let b="starting"===d.phase||"error"===d.phase,T="entry"===d.phase?d.invitation:null;return A(n,{children:A("div",{"data-devtools":"participant-entry",style:{display:"contents",pointerEvents:"auto"},children:b?A(i,{entry:{theme:f,themePreference:X,onThemePreferenceChange:H,ariaLabel:"starting"===d.phase?"Popmelt connecting":"Popmelt disconnected",action:null,logoOnly:!0,connected:!1,connection:P("span",{"data-popmelt-entry-content":!0,role:"status",style:{...j(g[f],!1),cursor:"default"},children:[A(w,{size:14,strokeWidth:1.5,"aria-hidden":"true"}),"starting"===d.phase?"Connecting…":"Disconnected"]})}}):A(m,{showHostLinkHelp:window.top===window&&["localhost","127.0.0.1","[::1]"].includes(location.hostname)&&!y(r.url)&&"/"===c(location.pathname),client:h.client,storage:localStorage,storageKey:`popmelt-admission:${r.projectId}`,theme:f,themePreference:X,onThemePreferenceChange:H,onAdmitted:h.admit,onJoin:T?h.join:void 0},T??"request-access")})})}export{H as default};
@@ -0,0 +1 @@
1
+ "use client";import{a as r,d as t}from"./chunk-GTVTUWGH.mjs";import"./chunk-SKM4ZXV5.mjs";import"./chunk-TXL2CR66.mjs";import"./chunk-KHDXOXYF.mjs";import"./chunk-SOGN7S54.mjs";import"./chunk-BJUSVIDN.mjs";import"./chunk-WNOLXY3Y.mjs";import"./chunk-G6BN5TAZ.mjs";import"./chunk-B3RA4XAR.mjs";import"./chunk-DBCBG5J6.mjs";import"./chunk-G2ZHJXHZ.mjs";import"./chunk-TMSGNHXH.mjs";import"./chunk-53SKVMWR.mjs";import"./chunk-3LZQLRZ2.mjs";import"./chunk-RJWFSAKE.mjs";import"./chunk-P2WAXWAZ.mjs";import"./chunk-2F2BVGFH.mjs";import"./chunk-RWZ7SVMO.mjs";import"./chunk-RK6UROPO.mjs";import"./chunk-5IZHN3A7.mjs";import"./chunk-AOTDTBQO.mjs";import"./chunk-HAZXZ5TU.mjs";import"./chunk-TVIKC33M.mjs";import"./chunk-25EXQOPI.mjs";import"./chunk-VXRRHXUP.mjs";import"./chunk-WP2SHSCG.mjs";import"./chunk-AAMUU2QA.mjs";import"./chunk-LH7HKUCK.mjs";import"./chunk-3VOEPWRL.mjs";import"./chunk-EILBHZDX.mjs";import"./chunk-XJJDBMZI.mjs";import"./chunk-OREALBUO.mjs";import"./chunk-B4DYUYX4.mjs";import"./chunk-CK3CDA3L.mjs";import"./chunk-WJVRGXOS.mjs";import{b as o}from"./chunk-BEGAJYOY.mjs";import{d as n,f as i,c as m,a as e}from"./chunk-AGCS65LT.mjs";import"./chunk-OA63PYHZ.mjs";import"./chunk-6RMM7JB6.mjs";import"./chunk-SUAHDXJZ.mjs";import"./chunk-PRPXMDZ7.mjs";import"./chunk-YGP6PPOZ.mjs";import{useState as c,useEffect as s,cloneElement as p}from"react";import{jsxs as h,jsx as u}from"react/jsx-runtime";function j({children:j,projectId:k,participantConfig:a}){let[l,d]=c(null),[A,I]=c("");if(s(()=>{let t,m,c=!1;return d(null),I(""),n(k).then(async n=>{if(c)return;let s=location.origin+e;m=i(s,n);let p=await o(s+"/status",{signal:AbortSignal.timeout(6e3)}),h=p.ok?await p.json():null;if(h?.projectId!==n.projectId)throw new Error("Phone access expired. Create a fresh pairing link in the project terminal.");if(!c){if(h.phoneParticipantId)t=await r({projectId:n.projectId,bridgeUrl:s,credential:{participantId:h.phoneParticipantId,token:""},runtimeStorage:sessionStorage,observedSource:{sourceId:n.projectId,revision:a?.revision??"unversioned"}});else if(a)throw new Error("This phone is not connected to the multiplayer host.");c?t?.dispose():d({bridgeUrl:s,projectId:n.projectId,connection:t})}}).catch(r=>{m?.(),c||I(r instanceof Error?r.message:"Phone pairing failed.")}),()=>{c=!0,t?.dispose(),m?.()}},[k,a]),A)return h("p",{role:"alert","data-devtools":"phone-pairing-error",children:[A," ",u("button",{type:"button",onClick:m,children:"Forget this pairing"})]});if(!l)return null;let X=p(j,{bridgeUrl:l.bridgeUrl,projectId:l.projectId});return l.connection?u(t,{connection:l.connection,onAccessRemoved:m,children:X}):X}export{j as PhoneHostGate};