@happyvertical/smrt-planner 0.57.6 → 0.57.7

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 (565) hide show
  1. package/agents/assistant.md +29 -2
  2. package/agents/shell.md +13 -0
  3. package/app/404.html +26 -29
  4. package/app/_app/immutable/assets/0.BaRFeYGU.css +1 -0
  5. package/app/_app/immutable/assets/AppShell.BkKNrxND.css +1 -0
  6. package/app/_app/immutable/assets/{ModelPage.FEM0ZnPM.css → ModelPage.SIoeO-AU.css} +1 -1
  7. package/app/_app/immutable/assets/app.BHwMQ9Zv.css +1 -0
  8. package/app/_app/immutable/assets/{forms.DXOeP4wZ.css → forms.BRdbPdvs.css} +1 -1
  9. package/app/_app/immutable/assets/icons.BDx21rPt.css +1 -0
  10. package/app/_app/immutable/assets/labels.Dxa6EyRI.css +1 -0
  11. package/app/_app/immutable/assets/planner.DOQVfcOi.css +1 -0
  12. package/app/_app/immutable/assets/state.C0UZEhxS.css +1 -0
  13. package/app/_app/immutable/chunks/{BPsie9Wr.js → B2uXaQfZ.js} +1 -1
  14. package/app/_app/immutable/chunks/{D2Ykv2Y3.js → BQLQsso4.js} +1 -1
  15. package/app/_app/immutable/chunks/BdOPgmQ_.js +11 -0
  16. package/app/_app/immutable/chunks/BeL8dJx9.js +4 -0
  17. package/app/_app/immutable/chunks/{DypPefJO.js → Bhd-3niN.js} +1 -1
  18. package/app/_app/immutable/chunks/{exPME6UK.js → BqEBz5Vq.js} +1 -1
  19. package/app/_app/immutable/chunks/{GdHEbDDH.js → BxyJ_Q7v.js} +1 -1
  20. package/app/_app/immutable/chunks/{Dyf3Cj8R.js → C2OYATC6.js} +1 -1
  21. package/app/_app/immutable/chunks/C6AANt9H.js +26 -0
  22. package/app/_app/immutable/chunks/{0as86J1A.js → C8FX0hli.js} +6 -6
  23. package/app/_app/immutable/chunks/{BSYvnYu8.js → CYhwv6d2.js} +1 -1
  24. package/app/_app/immutable/chunks/CdKHckEF.js +1 -0
  25. package/app/_app/immutable/chunks/CsaWd8kG.js +2 -0
  26. package/app/_app/immutable/chunks/Cwz7QFS4.js +2 -0
  27. package/app/_app/immutable/chunks/{CoXf-L_3.js → D3lXu_rt.js} +25 -25
  28. package/app/_app/immutable/chunks/{PsiVGwJV.js → D8MqcCKq.js} +1 -1
  29. package/app/_app/immutable/chunks/DF-0MxNw.js +1 -0
  30. package/app/_app/immutable/chunks/DGaFQflg.js +1 -0
  31. package/app/_app/immutable/chunks/DIgo5ngo.js +1 -0
  32. package/app/_app/immutable/chunks/{CdlkzC7D.js → Db12RzZi.js} +1 -1
  33. package/app/_app/immutable/chunks/{eNZ3ToP2.js → DfN2k_EX.js} +1 -1
  34. package/app/_app/immutable/chunks/DmHVTNcC.js +4 -0
  35. package/app/_app/immutable/chunks/{DrjdLb0M.js → DmdvNG82.js} +2 -2
  36. package/app/_app/immutable/chunks/{CwNhmq3e.js → DwIRC3h5.js} +1 -1
  37. package/app/_app/immutable/chunks/{Dzh-1KQR.js → FeyhlLIZ.js} +1 -1
  38. package/app/_app/immutable/chunks/ICDFUCZL.js +2 -0
  39. package/app/_app/immutable/chunks/{D31rqKs1.js → IDZmjRDr.js} +1 -1
  40. package/app/_app/immutable/chunks/JqlEoPqZ.js +1 -0
  41. package/app/_app/immutable/chunks/{D8rEUyzO.js → TcjpRcdI.js} +1 -1
  42. package/app/_app/immutable/chunks/Vt9hDpHd.js +1 -0
  43. package/app/_app/immutable/chunks/ezs6CGyc.js +1 -0
  44. package/app/_app/immutable/chunks/lUJaueNM.js +16 -0
  45. package/app/_app/immutable/entry/app.C5bxPKCP.js +2 -0
  46. package/app/_app/immutable/entry/start.CZvO61qD.js +1 -0
  47. package/app/_app/immutable/nodes/0.DFJFBCCB.js +7 -0
  48. package/app/_app/immutable/nodes/{1.CTatAlE5.js → 1.D_79m87b.js} +1 -1
  49. package/app/_app/immutable/nodes/{10.DHnK3kbB.js → 10.20u2-jxn.js} +1 -1
  50. package/app/_app/immutable/nodes/{11.Ck1kcQLu.js → 11.CvMq32jC.js} +1 -1
  51. package/app/_app/immutable/nodes/{12.oK17D56_.js → 12.Cd0cy1AC.js} +1 -1
  52. package/app/_app/immutable/nodes/{13.DlEsuw6F.js → 13.DYYS3YVQ.js} +1 -1
  53. package/app/_app/immutable/nodes/14.BEf5BJDn.js +1 -0
  54. package/app/_app/immutable/nodes/2.C_kLkHNl.js +24 -0
  55. package/app/_app/immutable/nodes/{3.DOL1VeVM.js → 3.CZw3hv8O.js} +1 -1
  56. package/app/_app/immutable/nodes/{4.CiKq5-ek.js → 4.WMU9NDex.js} +1 -1
  57. package/app/_app/immutable/nodes/{5.nKUg_W9L.js → 5.CuqxSfl4.js} +1 -1
  58. package/app/_app/immutable/nodes/{6.CVGw-hLa.js → 6.BXLQB7tR.js} +1 -1
  59. package/app/_app/immutable/nodes/{7.Clo6kG4w.js → 7.BZvxNeL2.js} +1 -1
  60. package/app/_app/immutable/nodes/{8.C3moca98.js → 8.Bj2O4pyx.js} +1 -1
  61. package/app/_app/immutable/nodes/{9.BnVJx5kW.js → 9.yeFzeUHj.js} +1 -1
  62. package/app/_app/version.json +1 -1
  63. package/app/advanced-styles/index.html +32 -33
  64. package/app/ai/index.html +37 -38
  65. package/app/blueprint/index.html +27 -30
  66. package/app/cookbook/index.html +27 -30
  67. package/app/index.html +36 -39
  68. package/app/m/ads/AdDeliveryTier/index.html +34 -35
  69. package/app/m/ads/AdEvent/index.html +34 -35
  70. package/app/m/ads/AdFormat/index.html +34 -35
  71. package/app/m/ads/AdGroup/index.html +34 -35
  72. package/app/m/ads/AdVariation/index.html +34 -35
  73. package/app/m/analytics/AnalyticsDataStream/index.html +34 -35
  74. package/app/m/analytics/AnalyticsEvent/index.html +34 -35
  75. package/app/m/analytics/AnalyticsProperty/index.html +34 -35
  76. package/app/m/analytics/AnalyticsReport/index.html +34 -35
  77. package/app/m/approvals/ApprovalEvent/index.html +34 -35
  78. package/app/m/approvals/ApprovalPolicy/index.html +34 -35
  79. package/app/m/approvals/ApprovalRequest/index.html +34 -35
  80. package/app/m/assets/Asset/attachments/index.html +36 -37
  81. package/app/m/assets/Asset/index.html +34 -35
  82. package/app/m/assets/AssetAssociation/index.html +35 -36
  83. package/app/m/assets/AssetMetafield/index.html +34 -35
  84. package/app/m/assets/AssetStatus/index.html +34 -35
  85. package/app/m/assets/AssetType/index.html +34 -35
  86. package/app/m/assets/Folder/index.html +34 -35
  87. package/app/m/chat/AgentSession/index.html +34 -35
  88. package/app/m/chat/ChatMessage/index.html +35 -36
  89. package/app/m/chat/ChatParticipant/index.html +35 -36
  90. package/app/m/chat/ChatReaction/index.html +34 -35
  91. package/app/m/chat/ChatRoom/index.html +34 -35
  92. package/app/m/chat/ChatThread/index.html +35 -36
  93. package/app/m/chat/VoiceGatewayTurn/index.html +34 -35
  94. package/app/m/chat/VoiceSession/index.html +34 -35
  95. package/app/m/commerce/Agreement/index.html +34 -35
  96. package/app/m/commerce/Cart/index.html +34 -35
  97. package/app/m/commerce/Contract/index.html +34 -35
  98. package/app/m/commerce/ContractLineItem/index.html +35 -36
  99. package/app/m/commerce/Customer/index.html +34 -35
  100. package/app/m/commerce/DocumentTax/index.html +34 -35
  101. package/app/m/commerce/Estimate/index.html +34 -35
  102. package/app/m/commerce/Fulfillment/index.html +34 -35
  103. package/app/m/commerce/FulfillmentLineItem/index.html +35 -36
  104. package/app/m/commerce/HistoricalCustomerFunds/index.html +34 -35
  105. package/app/m/commerce/HistoricalCustomerFundsAllocation/index.html +34 -35
  106. package/app/m/commerce/HistoricalSalesLine/index.html +34 -35
  107. package/app/m/commerce/Invoice/index.html +34 -35
  108. package/app/m/commerce/InvoiceLineItem/index.html +35 -36
  109. package/app/m/commerce/Lease/index.html +34 -35
  110. package/app/m/commerce/LicenseSale/index.html +34 -35
  111. package/app/m/commerce/Order/index.html +34 -35
  112. package/app/m/commerce/Payment/index.html +34 -35
  113. package/app/m/commerce/PaymentAllocation/index.html +35 -36
  114. package/app/m/commerce/PaymentInstrument/index.html +34 -35
  115. package/app/m/commerce/PaymentIntent/index.html +34 -35
  116. package/app/m/commerce/Payout/index.html +34 -35
  117. package/app/m/commerce/ProductionOrder/index.html +34 -35
  118. package/app/m/commerce/PurchaseContract/index.html +34 -35
  119. package/app/m/commerce/PurchaseOrder/index.html +34 -35
  120. package/app/m/commerce/SalesContract/index.html +34 -35
  121. package/app/m/commerce/SupplierQuote/index.html +34 -35
  122. package/app/m/commerce/TaxCode/index.html +34 -35
  123. package/app/m/commerce/TaxComponent/index.html +34 -35
  124. package/app/m/commerce/TaxSettings/index.html +34 -35
  125. package/app/m/commerce/TaxSummaryReport/index.html +34 -35
  126. package/app/m/commerce/Vendor/index.html +34 -35
  127. package/app/m/commerce/WholesaleOrder/index.html +34 -35
  128. package/app/m/content/Content/index.html +34 -35
  129. package/app/m/content/ContentContribution/index.html +34 -35
  130. package/app/m/content/ContentContributionAttachment/index.html +34 -35
  131. package/app/m/content/ContentContributionRevision/index.html +34 -35
  132. package/app/m/content/ContentContributionType/index.html +34 -35
  133. package/app/m/content/ContentContributor/index.html +34 -35
  134. package/app/m/content/ContentCorrection/index.html +34 -35
  135. package/app/m/content/ContentFeedSource/index.html +34 -35
  136. package/app/m/content/ContentGovernanceAssignment/index.html +34 -35
  137. package/app/m/content/ContentGovernancePolicy/index.html +34 -35
  138. package/app/m/content/ContentGovernanceProfile/index.html +34 -35
  139. package/app/m/content/ContentReference/index.html +34 -35
  140. package/app/m/content/ContentReview/index.html +34 -35
  141. package/app/m/content/ContentVersion/index.html +34 -35
  142. package/app/m/events/Event/index.html +34 -35
  143. package/app/m/events/EventParticipant/index.html +35 -36
  144. package/app/m/events/EventSeries/index.html +34 -35
  145. package/app/m/events/EventType/index.html +34 -35
  146. package/app/m/expenses/Expense/index.html +34 -35
  147. package/app/m/facts/Fact/index.html +34 -35
  148. package/app/m/facts/FactContent/index.html +34 -35
  149. package/app/m/facts/FactEvidence/index.html +34 -35
  150. package/app/m/facts/FactSource/index.html +34 -35
  151. package/app/m/facts/FactSubject/index.html +34 -35
  152. package/app/m/facts/FactTag/index.html +34 -35
  153. package/app/m/fields/FieldPolicy/index.html +34 -35
  154. package/app/m/fields/FieldPolicySuggestion/index.html +34 -35
  155. package/app/m/fields/FieldUsageCounter/index.html +34 -35
  156. package/app/m/images/Image/index.html +34 -35
  157. package/app/m/inventory/InventoryLocation/index.html +34 -35
  158. package/app/m/inventory/StockLevel/index.html +34 -35
  159. package/app/m/inventory/StockMovement/index.html +34 -35
  160. package/app/m/ledgers/Account/index.html +34 -35
  161. package/app/m/ledgers/Journal/index.html +34 -35
  162. package/app/m/ledgers/JournalEntry/index.html +35 -36
  163. package/app/m/ledgers/Ledger/index.html +34 -35
  164. package/app/m/manufacturing/Assembly/index.html +34 -35
  165. package/app/m/manufacturing/BillOfMaterials/index.html +34 -35
  166. package/app/m/manufacturing/BomLine/index.html +34 -35
  167. package/app/m/manufacturing/Operation/index.html +34 -35
  168. package/app/m/manufacturing/ProductionRun/index.html +34 -35
  169. package/app/m/manufacturing/ProductionRunCompletion/index.html +34 -35
  170. package/app/m/manufacturing/RoutingStep/index.html +34 -35
  171. package/app/m/marketing/Campaign/index.html +34 -35
  172. package/app/m/marketing/CampaignChannel/index.html +34 -35
  173. package/app/m/marketing/CampaignMetricSnapshot/index.html +34 -35
  174. package/app/m/messages/Account/index.html +34 -35
  175. package/app/m/messages/Attachment/index.html +34 -35
  176. package/app/m/messages/Blacklist/index.html +34 -35
  177. package/app/m/messages/Email/failed-sends/index.html +36 -37
  178. package/app/m/messages/Email/index.html +34 -35
  179. package/app/m/messages/Email/mailbox/index.html +36 -37
  180. package/app/m/messages/EmailAccount/index.html +34 -35
  181. package/app/m/messages/EmailAttachment/index.html +34 -35
  182. package/app/m/messages/EmailFolder/index.html +34 -35
  183. package/app/m/messages/Message/index.html +34 -35
  184. package/app/m/messages/MessagingEndpoint/index.html +34 -35
  185. package/app/m/messages/PersonaMessageRoute/index.html +34 -35
  186. package/app/m/messages/SlackAccount/index.html +34 -35
  187. package/app/m/messages/SlackMessage/index.html +34 -35
  188. package/app/m/messages/TelegramAccount/index.html +34 -35
  189. package/app/m/messages/Tweet/index.html +34 -35
  190. package/app/m/messages/TwitterAccount/index.html +34 -35
  191. package/app/m/messages/Whitelist/index.html +34 -35
  192. package/app/m/messages/ZulipAccount/index.html +34 -35
  193. package/app/m/places/Place/index.html +34 -35
  194. package/app/m/places/PlaceType/index.html +34 -35
  195. package/app/m/products/Category/index.html +34 -35
  196. package/app/m/products/Material/index.html +34 -35
  197. package/app/m/products/Product/index.html +34 -35
  198. package/app/m/products/Product/ingredients/index.html +36 -37
  199. package/app/m/products/ProductVariant/index.html +35 -36
  200. package/app/m/products/Sku/index.html +35 -36
  201. package/app/m/profiles/ApiKey/index.html +34 -35
  202. package/app/m/profiles/Bot/index.html +34 -35
  203. package/app/m/profiles/MagicLinkToken/index.html +34 -35
  204. package/app/m/profiles/NostrIdentity/index.html +34 -35
  205. package/app/m/profiles/OidcIdentity/index.html +34 -35
  206. package/app/m/profiles/Organization/index.html +34 -35
  207. package/app/m/profiles/Person/index.html +34 -35
  208. package/app/m/profiles/Profile/index.html +34 -35
  209. package/app/m/profiles/ProfileMetadata/index.html +34 -35
  210. package/app/m/profiles/ProfileMetafield/index.html +34 -35
  211. package/app/m/profiles/ProfileRelationship/index.html +34 -35
  212. package/app/m/profiles/ProfileRelationshipTerm/index.html +34 -35
  213. package/app/m/profiles/ProfileRelationshipType/index.html +34 -35
  214. package/app/m/profiles/ProfileType/index.html +34 -35
  215. package/app/m/projects/Comment/index.html +35 -36
  216. package/app/m/projects/Issue/index.html +34 -35
  217. package/app/m/projects/Label/index.html +34 -35
  218. package/app/m/projects/Project/index.html +34 -35
  219. package/app/m/projects/ProjectIntegration/index.html +34 -35
  220. package/app/m/projects/PullRequest/index.html +34 -35
  221. package/app/m/projects/Repository/index.html +34 -35
  222. package/app/m/properties/Property/index.html +34 -35
  223. package/app/m/properties/Zone/index.html +34 -35
  224. package/app/m/reports/RuntimeReport/index.html +38 -36
  225. package/app/m/reports/SmrtPrincipalReportRefreshTask/index.html +34 -35
  226. package/app/m/reports/SmrtReportLock/index.html +34 -35
  227. package/app/m/reports/SmrtReportRefreshTask/index.html +34 -35
  228. package/app/m/reports/SmrtReportRun/index.html +34 -35
  229. package/app/m/reports/SmrtReportSchedule/index.html +34 -35
  230. package/app/m/reports/SmrtReportWatermark/index.html +34 -35
  231. package/app/m/sales/Agreement/index.html +34 -35
  232. package/app/m/sales/AttributionException/index.html +34 -35
  233. package/app/m/sales/AttributionPolicy/index.html +34 -35
  234. package/app/m/sales/Commission/index.html +34 -35
  235. package/app/m/sales/CommissionAdjustment/index.html +34 -35
  236. package/app/m/sales/CommissionPayout/index.html +34 -35
  237. package/app/m/sales/CommissionPlan/index.html +34 -35
  238. package/app/m/sales/Earner/index.html +34 -35
  239. package/app/m/sales/EarnerSourceAttribution/index.html +34 -35
  240. package/app/m/sales/EarningEvent/index.html +34 -35
  241. package/app/m/sales/ExecutedAgreement/index.html +34 -35
  242. package/app/m/sales/Lead/index.html +34 -35
  243. package/app/m/sales/Opportunity/index.html +34 -35
  244. package/app/m/sales/OpportunityConversion/index.html +34 -35
  245. package/app/m/sales/PipelineDefinition/index.html +34 -35
  246. package/app/m/sales/PipelineStage/index.html +35 -36
  247. package/app/m/sales/Referral/index.html +34 -35
  248. package/app/m/sales/ReferralAgreement/index.html +34 -35
  249. package/app/m/sales/ReferralLink/index.html +34 -35
  250. package/app/m/sales/ReferralProgram/index.html +34 -35
  251. package/app/m/sales/ReferralTermSnapshot/index.html +34 -35
  252. package/app/m/sales/ReferralTouch/index.html +34 -35
  253. package/app/m/sales/Referrer/index.html +34 -35
  254. package/app/m/sales/SalesActivity/index.html +34 -35
  255. package/app/m/sales/SalesRepresentative/index.html +34 -35
  256. package/app/m/sites/Site/index.html +34 -35
  257. package/app/m/sites/SiteAgentBinding/index.html +34 -35
  258. package/app/m/social/OAuthState/index.html +34 -35
  259. package/app/m/social/SocialAccount/index.html +34 -35
  260. package/app/m/social/SocialPost/index.html +34 -35
  261. package/app/m/social/SocialPostAnalyticsSnapshot/index.html +34 -35
  262. package/app/m/subscriptions/BillingAdjustment/index.html +34 -35
  263. package/app/m/subscriptions/ClientCharge/index.html +34 -35
  264. package/app/m/subscriptions/CreditGrant/index.html +34 -35
  265. package/app/m/subscriptions/PricingRule/index.html +34 -35
  266. package/app/m/subscriptions/RetailCharge/index.html +34 -35
  267. package/app/m/subscriptions/SpendingPolicy/index.html +34 -35
  268. package/app/m/subscriptions/SubscriptionPlan/index.html +34 -35
  269. package/app/m/subscriptions/TenantSubscription/index.html +34 -35
  270. package/app/m/subscriptions/TenantUsageMetric/index.html +34 -35
  271. package/app/m/support/ServiceTimeEntry/index.html +34 -35
  272. package/app/m/support/SupportAiRun/index.html +34 -35
  273. package/app/m/support/SupportAvailability/index.html +34 -35
  274. package/app/m/support/SupportCase/index.html +34 -35
  275. package/app/m/support/SupportCaseEvent/index.html +34 -35
  276. package/app/m/support/SupportChannelBinding/index.html +34 -35
  277. package/app/m/support/SupportCharge/index.html +34 -35
  278. package/app/m/support/SupportCompensation/index.html +34 -35
  279. package/app/m/support/SupportCompensationPlan/index.html +34 -35
  280. package/app/m/support/SupportEscalation/index.html +34 -35
  281. package/app/m/support/SupportInteraction/index.html +34 -35
  282. package/app/m/support/SupportPlan/index.html +34 -35
  283. package/app/m/support/SupportPolicy/index.html +34 -35
  284. package/app/m/support/SupportQualification/index.html +34 -35
  285. package/app/m/support/SupportServiceTarget/index.html +34 -35
  286. package/app/m/support/SupportSpecialist/index.html +34 -35
  287. package/app/m/support/SupportWorkLink/index.html +34 -35
  288. package/app/m/tags/Tag/index.html +34 -35
  289. package/app/m/tags/TagAlias/index.html +34 -35
  290. package/app/m/timesheets/AttendanceBreak/index.html +34 -35
  291. package/app/m/timesheets/AttendancePunch/index.html +34 -35
  292. package/app/m/timesheets/AttendanceSegment/index.html +34 -35
  293. package/app/m/timesheets/ServiceChargeSnapshot/index.html +34 -35
  294. package/app/m/timesheets/ServiceCompensationSnapshot/index.html +34 -35
  295. package/app/m/timesheets/ServiceTimeEntry/index.html +34 -35
  296. package/app/m/users/Group/index.html +34 -35
  297. package/app/m/users/GroupMember/index.html +34 -35
  298. package/app/m/users/GroupRole/index.html +34 -35
  299. package/app/m/users/Membership/index.html +35 -36
  300. package/app/m/users/MembershipOverride/index.html +34 -35
  301. package/app/m/users/Permission/index.html +34 -35
  302. package/app/m/users/Role/index.html +34 -35
  303. package/app/m/users/RolePermission/index.html +34 -35
  304. package/app/m/users/Session/index.html +34 -35
  305. package/app/m/users/Tenant/index.html +34 -35
  306. package/app/m/users/TenantIntegration/index.html +34 -35
  307. package/app/m/users/TenantPermissionOverride/index.html +34 -35
  308. package/app/m/users/User/index.html +34 -35
  309. package/app/m/video/Character/index.html +34 -35
  310. package/app/m/video/CharacterAsset/index.html +34 -35
  311. package/app/m/video/CompositeJob/index.html +34 -35
  312. package/app/m/video/Performer/index.html +34 -35
  313. package/app/m/video/PerformerAsset/index.html +34 -35
  314. package/app/m/video/Scene/index.html +34 -35
  315. package/app/m/video/SceneAsset/index.html +34 -35
  316. package/app/m/video/VideoComposition/index.html +34 -35
  317. package/app/m/video/VideoCompositionAsset/index.html +34 -35
  318. package/app/m/video/VideoSequence/index.html +34 -35
  319. package/app/m/video/VideoSequenceAsset/index.html +34 -35
  320. package/app/m/video/VideoShot/index.html +34 -35
  321. package/app/m/video/VideoShotAsset/index.html +34 -35
  322. package/app/m/video/VideoShotCharacter/index.html +34 -35
  323. package/app/m/video/VideoWorkflow/index.html +34 -35
  324. package/app/m/voice/VoiceOutput/index.html +34 -35
  325. package/app/m/voice/VoiceProfile/index.html +34 -35
  326. package/app/m/voice/VoiceSample/index.html +34 -35
  327. package/app/mcp.html +2 -2
  328. package/app/packages/ads/index.html +29 -32
  329. package/app/packages/analytics/index.html +29 -32
  330. package/app/packages/approvals/index.html +29 -32
  331. package/app/packages/assets/index.html +29 -32
  332. package/app/packages/chat/index.html +29 -32
  333. package/app/packages/comments/index.html +29 -32
  334. package/app/packages/commerce/index.html +29 -32
  335. package/app/packages/content/index.html +29 -32
  336. package/app/packages/events/index.html +29 -32
  337. package/app/packages/expenses/index.html +29 -32
  338. package/app/packages/facts/index.html +29 -32
  339. package/app/packages/fields/index.html +29 -32
  340. package/app/packages/human-resources/index.html +29 -32
  341. package/app/packages/images/index.html +29 -32
  342. package/app/packages/index.html +28 -31
  343. package/app/packages/ingestion/index.html +29 -32
  344. package/app/packages/inventory/index.html +29 -32
  345. package/app/packages/ledgers/index.html +29 -32
  346. package/app/packages/manufacturing/index.html +29 -32
  347. package/app/packages/marketing/index.html +29 -32
  348. package/app/packages/messages/index.html +29 -32
  349. package/app/packages/places/index.html +29 -32
  350. package/app/packages/preferences/index.html +29 -32
  351. package/app/packages/products/index.html +29 -32
  352. package/app/packages/profiles/index.html +29 -32
  353. package/app/packages/projects/index.html +29 -32
  354. package/app/packages/properties/index.html +29 -32
  355. package/app/packages/reports/index.html +29 -32
  356. package/app/packages/sales/index.html +29 -32
  357. package/app/packages/sites/index.html +29 -32
  358. package/app/packages/social/index.html +29 -32
  359. package/app/packages/subscriptions/index.html +29 -32
  360. package/app/packages/support/index.html +29 -32
  361. package/app/packages/tags/index.html +29 -32
  362. package/app/packages/timesheets/index.html +29 -32
  363. package/app/packages/users/index.html +29 -32
  364. package/app/packages/video/index.html +29 -32
  365. package/app/packages/voice/index.html +29 -32
  366. package/app/packages/webhooks/index.html +29 -32
  367. package/app/recipes/account-access/help/index.html +30 -33
  368. package/app/recipes/account-access/index.html +34 -36
  369. package/app/recipes/activity/help/index.html +30 -33
  370. package/app/recipes/activity/index.html +34 -36
  371. package/app/recipes/agreements/help/index.html +30 -33
  372. package/app/recipes/agreements/index.html +34 -36
  373. package/app/recipes/analytics.reports/help/index.html +30 -33
  374. package/app/recipes/analytics.reports/index.html +34 -36
  375. package/app/recipes/assets/help/index.html +30 -33
  376. package/app/recipes/assets/index.html +34 -36
  377. package/app/recipes/billing/help/index.html +30 -33
  378. package/app/recipes/billing/index.html +34 -36
  379. package/app/recipes/chat.assistant/help/index.html +30 -33
  380. package/app/recipes/chat.assistant/index.html +34 -36
  381. package/app/recipes/comments/help/index.html +30 -33
  382. package/app/recipes/comments/index.html +34 -36
  383. package/app/recipes/commerce.customers/help/index.html +30 -33
  384. package/app/recipes/commerce.customers/index.html +34 -36
  385. package/app/recipes/commerce.estimates/help/index.html +30 -33
  386. package/app/recipes/commerce.estimates/index.html +34 -36
  387. package/app/recipes/commerce.purchases/help/index.html +30 -33
  388. package/app/recipes/commerce.purchases/index.html +34 -36
  389. package/app/recipes/commerce.sales/help/index.html +30 -33
  390. package/app/recipes/commerce.sales/index.html +34 -36
  391. package/app/recipes/commerce.vendors/help/index.html +30 -33
  392. package/app/recipes/commerce.vendors/index.html +34 -36
  393. package/app/recipes/commerce.wholesale/help/index.html +30 -33
  394. package/app/recipes/commerce.wholesale/index.html +34 -36
  395. package/app/recipes/events.calendar/help/index.html +30 -33
  396. package/app/recipes/events.calendar/index.html +34 -36
  397. package/app/recipes/expenses.tracking/help/index.html +30 -33
  398. package/app/recipes/expenses.tracking/index.html +34 -36
  399. package/app/recipes/fields.form-customization/help/index.html +30 -33
  400. package/app/recipes/fields.form-customization/index.html +34 -36
  401. package/app/recipes/ingestion/help/index.html +30 -33
  402. package/app/recipes/ingestion/index.html +34 -36
  403. package/app/recipes/integrations/help/index.html +30 -33
  404. package/app/recipes/integrations/index.html +34 -36
  405. package/app/recipes/inventory.stock/help/index.html +30 -33
  406. package/app/recipes/inventory.stock/index.html +34 -36
  407. package/app/recipes/ledgers.bookkeeping/help/index.html +30 -33
  408. package/app/recipes/ledgers.bookkeeping/index.html +34 -36
  409. package/app/recipes/messages/help/index.html +30 -33
  410. package/app/recipes/messages/index.html +34 -36
  411. package/app/recipes/products/help/index.html +30 -33
  412. package/app/recipes/products/index.html +34 -36
  413. package/app/recipes/projects.tracker/help/index.html +30 -33
  414. package/app/recipes/projects.tracker/index.html +34 -36
  415. package/app/recipes/reports.materialized/help/index.html +30 -33
  416. package/app/recipes/reports.materialized/index.html +34 -36
  417. package/app/recipes/reports.runtime/help/index.html +31 -34
  418. package/app/recipes/reports.runtime/index.html +35 -37
  419. package/app/recipes/sales.pipeline/help/index.html +30 -33
  420. package/app/recipes/sales.pipeline/index.html +34 -36
  421. package/app/recipes/tags.taxonomy/help/index.html +30 -33
  422. package/app/recipes/tags.taxonomy/index.html +34 -36
  423. package/app/recipes/team-collaboration/help/index.html +30 -33
  424. package/app/recipes/team-collaboration/index.html +34 -36
  425. package/app/recipes/timesheets.time-entries/help/index.html +30 -33
  426. package/app/recipes/timesheets.time-entries/index.html +34 -36
  427. package/app/s/custom-accounts/index.html +27 -30
  428. package/app/s/custom-appointments/index.html +27 -30
  429. package/app/s/custom-billing/index.html +27 -30
  430. package/app/s/custom-bookings/index.html +27 -30
  431. package/app/s/custom-buying/index.html +27 -30
  432. package/app/s/custom-checkout/index.html +27 -30
  433. package/app/s/custom-classes/index.html +27 -30
  434. package/app/s/custom-clients/index.html +27 -30
  435. package/app/s/custom-events/index.html +27 -30
  436. package/app/s/custom-fleet/index.html +27 -30
  437. package/app/s/custom-gigs/index.html +27 -30
  438. package/app/s/custom-giving/index.html +27 -30
  439. package/app/s/custom-instruments/index.html +27 -30
  440. package/app/s/custom-jobs/index.html +27 -30
  441. package/app/s/custom-kitchen/index.html +27 -30
  442. package/app/s/custom-lessons/index.html +27 -30
  443. package/app/s/custom-material/index.html +27 -30
  444. package/app/s/custom-meetings/index.html +27 -30
  445. package/app/s/custom-members/index.html +27 -30
  446. package/app/s/custom-merch/index.html +27 -30
  447. package/app/s/custom-money/index.html +27 -30
  448. package/app/s/custom-paint/index.html +27 -30
  449. package/app/s/custom-parts/index.html +27 -30
  450. package/app/s/custom-rentals/index.html +27 -30
  451. package/app/s/custom-roastery/index.html +27 -30
  452. package/app/s/custom-schedule/index.html +27 -30
  453. package/app/s/custom-shelf/index.html +27 -30
  454. package/app/s/custom-shop/index.html +27 -30
  455. package/app/s/custom-students/index.html +27 -30
  456. package/app/s/custom-wholesale/index.html +27 -30
  457. package/app/s/custom-work/index.html +27 -30
  458. package/app/s/custom-yard/index.html +27 -30
  459. package/app/s/section-access-control/index.html +27 -30
  460. package/app/s/section-account-security/index.html +27 -30
  461. package/app/s/section-accounting/index.html +27 -30
  462. package/app/s/section-activity/index.html +27 -30
  463. package/app/s/section-agreements/index.html +27 -30
  464. package/app/s/section-analytics/index.html +27 -30
  465. package/app/s/section-assets/index.html +27 -30
  466. package/app/s/section-billing/index.html +27 -30
  467. package/app/s/section-calendar/index.html +27 -30
  468. package/app/s/section-catalog/index.html +27 -30
  469. package/app/s/section-chat.assistant/index.html +27 -30
  470. package/app/s/section-comments/index.html +27 -30
  471. package/app/s/section-fields.form-customization/index.html +27 -30
  472. package/app/s/section-ingestion/index.html +27 -30
  473. package/app/s/section-integrations/index.html +27 -30
  474. package/app/s/section-messages/index.html +27 -30
  475. package/app/s/section-more/index.html +27 -30
  476. package/app/s/section-operations/index.html +27 -30
  477. package/app/s/section-projects/index.html +27 -30
  478. package/app/s/section-purchasing/index.html +27 -30
  479. package/app/s/section-reports.materialized/index.html +27 -30
  480. package/app/s/section-reports.runtime/index.html +27 -30
  481. package/app/s/section-sales/index.html +27 -30
  482. package/app/s/section-taxonomy/index.html +27 -30
  483. package/app/s/section-team/index.html +27 -30
  484. package/app/s/section-work/index.html +27 -30
  485. package/dist/assistant/change.d.ts +10 -1
  486. package/dist/assistant/change.d.ts.map +1 -1
  487. package/dist/assistant/change.js +6 -1
  488. package/dist/assistant/prompt.d.ts +10 -1
  489. package/dist/assistant/prompt.d.ts.map +1 -1
  490. package/dist/assistant/prompt.js +42 -7
  491. package/dist/assistant/session.svelte.d.ts +6 -0
  492. package/dist/assistant/session.svelte.d.ts.map +1 -1
  493. package/dist/assistant/session.svelte.js +6 -0
  494. package/dist/assistant/transport.d.ts +23 -3
  495. package/dist/assistant/transport.d.ts.map +1 -1
  496. package/dist/assistant/transport.js +356 -13
  497. package/dist/catalog/catalog.json +107 -41
  498. package/dist/components/BrowserAssistant.svelte +26 -0
  499. package/dist/components/BrowserAssistant.svelte.d.ts.map +1 -1
  500. package/dist/components/ModelPage.svelte +36 -4
  501. package/dist/components/ModelPage.svelte.d.ts.map +1 -1
  502. package/dist/components/PlannerReports.svelte +61 -0
  503. package/dist/components/PlannerReports.svelte.d.ts +10 -0
  504. package/dist/components/PlannerReports.svelte.d.ts.map +1 -0
  505. package/dist/components/PlannerSavedReportsWidget.svelte +38 -0
  506. package/dist/components/PlannerSavedReportsWidget.svelte.d.ts +9 -0
  507. package/dist/components/PlannerSavedReportsWidget.svelte.d.ts.map +1 -0
  508. package/dist/components/ReportProposalCard.svelte +63 -0
  509. package/dist/components/ReportProposalCard.svelte.d.ts +17 -0
  510. package/dist/components/ReportProposalCard.svelte.d.ts.map +1 -0
  511. package/dist/components/SectionOverview.svelte +22 -1
  512. package/dist/components/SectionOverview.svelte.d.ts.map +1 -1
  513. package/dist/core/prompt.d.ts.map +1 -1
  514. package/dist/core/prompt.js +7 -1
  515. package/dist/core/reply.d.ts +6 -0
  516. package/dist/core/reply.d.ts.map +1 -1
  517. package/dist/core/reply.js +11 -0
  518. package/dist/data/planner-source.d.ts.map +1 -1
  519. package/dist/data/planner-source.js +4 -1
  520. package/dist/overviews/definitions.d.ts.map +1 -1
  521. package/dist/overviews/definitions.js +6 -1
  522. package/dist/overviews/registry.d.ts.map +1 -1
  523. package/dist/overviews/registry.js +9 -5
  524. package/dist/planner/Planner.svelte +17 -0
  525. package/dist/planner/Planner.svelte.d.ts.map +1 -1
  526. package/dist/planner/instance.d.ts +6 -0
  527. package/dist/planner/instance.d.ts.map +1 -1
  528. package/dist/planner/shell.d.ts.map +1 -1
  529. package/dist/planner/shell.js +3 -1
  530. package/dist/reports/intent.d.ts +106 -0
  531. package/dist/reports/intent.d.ts.map +1 -0
  532. package/dist/reports/intent.js +667 -0
  533. package/dist/reports/planner.d.ts +33 -0
  534. package/dist/reports/planner.d.ts.map +1 -0
  535. package/dist/reports/planner.js +60 -0
  536. package/dist/reports/sources.d.ts +36 -0
  537. package/dist/reports/sources.d.ts.map +1 -0
  538. package/dist/reports/sources.js +125 -0
  539. package/dist/reports/store.d.ts +64 -0
  540. package/dist/reports/store.d.ts.map +1 -0
  541. package/dist/reports/store.js +214 -0
  542. package/dist/smrt-version.d.ts +1 -1
  543. package/dist/smrt-version.js +1 -1
  544. package/package.json +54 -54
  545. package/app/_app/immutable/assets/0.C8CwV4Fz.css +0 -1
  546. package/app/_app/immutable/assets/AppShell.DrL8T9I9.css +0 -1
  547. package/app/_app/immutable/assets/app.4ScdTV_S.css +0 -1
  548. package/app/_app/immutable/assets/labels.AVmg4hBz.css +0 -1
  549. package/app/_app/immutable/assets/state.CkVocVUJ.css +0 -1
  550. package/app/_app/immutable/chunks/B7d7dGCP.js +0 -1
  551. package/app/_app/immutable/chunks/C3nKLKKd.js +0 -1
  552. package/app/_app/immutable/chunks/CXKa_xdk.js +0 -4
  553. package/app/_app/immutable/chunks/CdBvpdnq.js +0 -4
  554. package/app/_app/immutable/chunks/DBp81N-t.js +0 -24
  555. package/app/_app/immutable/chunks/DzRTyOpH.js +0 -1
  556. package/app/_app/immutable/chunks/GVQNHDp5.js +0 -1
  557. package/app/_app/immutable/chunks/M-CuJzQN.js +0 -1
  558. package/app/_app/immutable/chunks/ORlJSBRk.js +0 -1
  559. package/app/_app/immutable/chunks/gMSmS-_y.js +0 -2
  560. package/app/_app/immutable/chunks/jol435F5.js +0 -11
  561. package/app/_app/immutable/entry/app.C_C191oT.js +0 -2
  562. package/app/_app/immutable/entry/start.C01jT-Kj.js +0 -1
  563. package/app/_app/immutable/nodes/0._tbUx7Ky.js +0 -9
  564. package/app/_app/immutable/nodes/14.sDZ3z4Zh.js +0 -1
  565. package/app/_app/immutable/nodes/2.GYBHfqdI.js +0 -24
@@ -1,24 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./BbwIep6z.js","./uBIymjUX.js","./BQxY8kkL.js"])))=>i.map(i=>d[i]);
2
- import{$ as e,Mt as t,bt as n,ct as r,gt as i,nt as a,ot as o,vt as s}from"./DG3qFFTE.js";import{t as c}from"./uBIymjUX.js";import{F as l,lt as u}from"./CoXf-L_3.js";import{g as d}from"./CdBvpdnq.js";import{n as f}from"./DrjdLb0M.js";import{n as p,r as m}from"./GdHEbDDH.js";import{a as h,t as g}from"./BQxY8kkL.js";import{_,a as v,c as y,g as b,h as x,l as S,n as C,o as w,p as T,u as E}from"./C3nKLKKd.js";import{b as D,c as O,o as ee,r as te,t as ne}from"./B7d7dGCP.js";import{n as k,t as re}from"./Dzh-1KQR.js";async function ie(e={}){let t=e.window??(typeof window<`u`?window:void 0),n=e.navigator??(typeof navigator<`u`?navigator:void 0);return!t||!(`SpeechRecognition`in t)&&!(`webkitSpeechRecognition`in t)?`missing`:n&&`brave`in n&&n.brave||/\bElectron\//.test(n?.userAgent??``)?`unreliable`:`works`}function ae(e){return new Worker(new URL(`../workers/local-speech.worker-CU_DjhLr.js`,import.meta.url).href,{name:e?.name})}var oe=2**28,se=16,ce=.95;function le(e){if(e===0)return 1;let t=Math.PI*e;return Math.sin(t)/t}function ue(e,t,n){for(let[e,r]of[[`fromRate`,t],[`toRate`,n]])if(!Number.isFinite(r)||r<=0)throw new h(`invalid_argument`,`${e} must be a positive finite number (got ${String(r)})`);let r=Math.floor(e.length*n/t);if(r>oe)throw new h(`invalid_argument`,`resampled output would be ${r} samples; the limit is ${oe}`);if(t===n)return e.slice();let i=new Float32Array(r),a=t/n,o=a>1?ce/a:1,s=se/o,c=e.length-1;for(let t=0;t<r;t+=1){let n=t*a,r=Math.max(0,Math.ceil(n-s)),l=Math.min(c,Math.floor(n+s)),u=0,d=0;for(let t=r;t<=l;t+=1){let r=t-n,i=.5+.5*Math.cos(Math.PI*r/s),a=o*le(o*r)*i;u+=a*e[t],d+=a}i[t]=d===0?0:u/d}return i}var A={silenceMs:800,minSpeechMs:150,preRollMs:300,maxUtteranceMs:3e4,sensitivity:.5,calibrateMs:300},de=.0015,fe=.003,pe=.006,me=.2,he=.02,ge=2e3,_e=250;function ve(e,t,n){return Math.min(n,Math.max(t,e))}function ye(e={}){let t=(e,t,n)=>typeof e==`number`&&Number.isFinite(e)?Math.max(n,e):t;return{silenceMs:t(e.silenceMs,A.silenceMs,20),minSpeechMs:t(e.minSpeechMs,A.minSpeechMs,0),preRollMs:t(e.preRollMs,A.preRollMs,0),maxUtteranceMs:t(e.maxUtteranceMs,A.maxUtteranceMs,1e3),sensitivity:ve(typeof e.sensitivity==`number`&&Number.isFinite(e.sensitivity)?e.sensitivity:A.sensitivity,0,1),calibrateMs:t(e.calibrateMs,A.calibrateMs,0)}}function be(e){let t=e.length;if(t===0)return 0;let n=0;for(let r=0;r<t;r++){let t=e[r];n+=t*t}return Math.sqrt(n/t)}function xe(e={}){let t=ye(e),n=6-4*t.sensitivity,r=.02-.015*t.sensitivity,i=fe,a=0,o=[],s=!1,c=0,l=0,u=0,d=()=>Math.max(i*n,r),f=()=>Math.max(d()*.6,i*1.5),p=()=>{s=!1,c=0,l=0,u=0};return{get speaking(){return s},get noiseFloor(){return i},get threshold(){return d()},push(e,n=20){let r=[],m=Number.isFinite(e)?Math.max(0,e):0,h=ve(m/(d()*3),0,1),g=a<t.calibrateMs;if(g&&(a+=n,!s)){o.push(m);let e=[...o].sort((e,t)=>e-t);i=ve(e[Math.min(e.length-1,Math.floor(e.length*me))]??fe,de,pe)}if(!s){if(m>d())c+=n,c>=t.minSpeechMs&&(s=!0,l=0,u=c,r.push({type:`start`,leadMs:t.preRollMs+c}),c=0);else if(g)c=0;else{c=0;let e=n/ge*(m<i?4:1);i=ve(i+(m-i)*Math.min(1,e),de,he)}return{events:r,level:h,speaking:s}}return u+=n,m>f()?l=0:l+=n,l>=t.silenceMs?(r.push({type:`end`,reason:`silence`,trailingSilenceMs:l}),p()):u>=t.maxUtteranceMs&&(r.push({type:`split`}),u=0,l=0),{events:r,level:h,speaking:s}},flush(){let e=[];return s&&e.push({type:`end`,reason:`flush`,trailingSilenceMs:l}),p(),e}}}function Se(e){let t=ye(e),n=xe(t),r=Math.max(1,Math.round(e.sampleRate*20/1e3)),i=r/e.sampleRate*1e3,a=Math.ceil((t.preRollMs+t.minSpeechMs)/i)+1,o=[],s=new Float32Array,c=null,l=!1,u=(t,n,r)=>{let a=Math.max(0,Math.floor((r-_e)/i)),o=t.slice(0,Math.max(1,t.length-a)),s=0;for(let e of o)s+=e.length;let c=new Float32Array(s),l=0;for(let e of o)c.set(e,l),l+=e.length;e.onUtterance({pcm:c,sampleRate:e.sampleRate,durationMs:s/e.sampleRate*1e3,reason:n})},d=t=>{t!==l&&(l=t,e.onSpeaking?.(t))},f=s=>{let l=n.push(be(s),i);e.onLevel?.(l.level),o.push(s),o.length>a&&o.shift(),c&&c.push(s);for(let e of l.events)if(e.type===`start`){c=[...o];let e=Math.ceil(t.preRollMs/i),n=Math.max(0,o.length-Math.ceil(t.minSpeechMs/i));for(let t=n;t<e;t++)c.unshift(new Float32Array(r))}else if(e.type===`end`){let t=c??[];c=null,o.length=0,t.length>0&&u(t,e.reason,e.trailingSilenceMs)}else if(e.type===`split`){let e=c??[];c=[],e.length>0&&u(e,`max`,0)}d(n.speaking)};return{get speaking(){return n.speaking},segmenter:n,push(e){let t=e;s.length>0&&(t=new Float32Array(s.length+e.length),t.set(s,0),t.set(e,s.length));let n=0;for(;n+r<=t.length;)f(t.slice(n,n+r)),n+=r;s=t.slice(n)},flush(){let t=n.flush();for(let e of t)e.type===`end`&&c&&c.length>0&&u(c,`flush`,e.trailingSilenceMs);c=null,o.length=0,s=new Float32Array,d(!1),e.onLevel?.(0)},discard(){n.flush(),c=null,o.length=0,s=new Float32Array,d(!1),e.onLevel?.(0)}}}var Ce=44,we=4294967295,Te=1;function Ee(e){let t=new Int16Array(e.length);for(let n=0;n<e.length;n+=1){let r=e[n];Number.isNaN(r)||(t[n]=Math.min(32767,Math.round((r>1?1:r<-1?-1:r)*32768)))}return t}function De(e,t){if(!Number.isInteger(e)||e<1||e*2>we)throw new h(`invalid_argument`,`${t} must be a positive integer sample rate (got ${String(e)})`)}function Oe(e,t,n){for(let r=0;r<n.length;r+=1)e.setUint8(t+r,n.charCodeAt(r))}function ke(e,t){De(t,`sampleRate`);let n=e.length*2;if(n+Ce-8>we)throw new h(`invalid_argument`,`too many samples for a single WAV (4 GiB limit)`);let r=e instanceof Int16Array?e:Ee(e),i=new Uint8Array(Ce+n),a=new DataView(i.buffer);Oe(a,0,`RIFF`),a.setUint32(4,36+n,!0),Oe(a,8,`WAVE`),Oe(a,12,`fmt `),a.setUint32(16,16,!0),a.setUint16(20,Te,!0),a.setUint16(22,1,!0),a.setUint32(24,t,!0),a.setUint32(28,t*2,!0),a.setUint16(32,2,!0),a.setUint16(34,16,!0),Oe(a,36,`data`),a.setUint32(40,n,!0);for(let e=0;e<r.length;e+=1)a.setInt16(Ce+e*2,r[e],!0);return i}var Ae=`hv-pcm-tap`,je=`
3
- class HvPcmTap extends AudioWorkletProcessor {
4
- process(inputs) {
5
- const channels = inputs[0];
6
- if (channels && channels.length > 0 && channels[0].length > 0) {
7
- const frames = channels[0].length;
8
- const mono = new Float32Array(frames);
9
- for (let c = 0; c < channels.length; c += 1) {
10
- const data = channels[c];
11
- for (let i = 0; i < frames; i += 1) mono[i] += data[i];
12
- }
13
- if (channels.length > 1) {
14
- for (let i = 0; i < frames; i += 1) mono[i] /= channels.length;
15
- }
16
- this.port.postMessage(mono, [mono.buffer]);
17
- }
18
- return true;
19
- }
20
- }
21
- registerProcessor('${Ae}', HvPcmTap);
22
- `;function Me(){return typeof AudioContext<`u`&&typeof AudioWorkletNode<`u`&&typeof Blob<`u`&&typeof URL<`u`&&typeof URL.createObjectURL==`function`}function Ne(e,t){let{sampleRate:n,maxDurationMs:r}=t;if(!Number.isInteger(n)||n<1)throw RangeError(`sampleRate must be a positive integer`);if(!Number.isFinite(r)||r<=0)throw RangeError(`maxDurationMs must be a positive number`);if(!Me())throw new g(`unsupported`,`PCM capture needs AudioContext, AudioWorkletNode and Blob URLs`);let i=new AudioContext,a=Math.ceil(r/1e3*i.sampleRate),o=[],s=0,c=!1,l=!1,u=!1,d=!1,f,p,m,h,_=e=>{if(d)return;let n=e.data;if(t.onSamples?.(n,i.sampleRate),t.retain===!1)return;let r=a-s;n.length>r&&(n=n.subarray(0,Math.max(0,r)),c=!0),n.length>0&&(o.push(n),s+=n.length),s>=a&&!l&&(l=!0,t.onLimit?.())},v=()=>{if(f!==void 0){let e=f;f=void 0;try{URL.revokeObjectURL(e)}catch{}}},y=()=>{if(h)return h;d=!0,v(),m&&(m.port.onmessage=null);try{p?.disconnect(),m?.disconnect()}catch{}return h=(async()=>{try{i.state!==`closed`&&await i.close()}catch{}})(),h},b=(async()=>{f=URL.createObjectURL(new Blob([je],{type:`text/javascript`}));try{await i.audioWorklet.addModule(f)}finally{v()}d||(p=i.createMediaStreamSource(e),m=new AudioWorkletNode(i,Ae,{numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1]}),m.port.onmessage=_,p.connect(m),m.connect(i.destination),i.state===`suspended`&&await i.resume())})();b.catch(()=>void 0);let x;return{ready:b,stop(){return x??=(async()=>{try{await b}catch(e){throw await y(),new g(`setup_failed`,`PCM capture could not start`,e)}if(await y(),u)throw new g(`cancelled`,`PCM capture was cancelled`);let e=new Float32Array(s),t=0;for(let n of o.splice(0))e.set(n,t),t+=n.length;let r=ue(e,i.sampleRate,n);return{samples:r,wav:ke(r,n),truncated:c}})(),x},cancel(){u||(u=!0,o.length=0,y())}}}var Pe=16e3;function Fe(){return Me()&&typeof navigator<`u`&&typeof navigator.mediaDevices?.getUserMedia==`function`}var Ie=36e5;async function Le(e={}){let t=e.createCapture??Ne;if(!e.createCapture&&!Fe()&&!e.stream)throw new g(`unsupported`,`Hands-free capture needs the microphone API and Web Audio`);let n=!e.stream,r=e.stream??await navigator.mediaDevices.getUserMedia(e.constraints??{audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),i={speechstart:new Set,speechend:new Set,level:new Set},a=(e,t)=>{for(let n of[...i[e]])try{n(t)}catch{}},o,s=!1,c=!1,l=0,u=Math.max(0,e.resumeGuardMs??350),d=()=>{if(n)for(let e of r.getTracks())e.stop()},f;try{f=t(r,{sampleRate:Pe,maxDurationMs:Ie,retain:!1,onSamples:(t,n)=>{s||c||(l>0?l-=t.length/n*1e3:(o??=Se({...e,sampleRate:n,onSpeaking:e=>{e&&a(`speechstart`,{})},onLevel:e=>a(`level`,{level:e}),onUtterance:e=>{let t=ue(e.pcm,e.sampleRate,Pe);a(`speechend`,{samples:t,sampleRate:Pe,durationMs:e.durationMs,reason:e.reason})}}),o.push(t)))}})}catch(e){throw d(),e}if(f.ready)try{await f.ready}catch(e){throw s=!0,f.cancel(),d(),new g(`setup_failed`,`Hands-free capture could not start`,e)}let p=async e=>{s||(e&&o?.flush(),s=!0,f.cancel(),d())};return{on(e,t){let n=i[e];return n.add(t),()=>{n.delete(t)}},get speaking(){return o?.speaking??!1},get suspended(){return c},suspend(){s||c||(c=!0,l=0,o?.discard(),a(`level`,{level:0}))},resume(){!s&&c&&(c=!1,l=u)},stop:()=>p(!0),cancel:()=>{p(!1)}}}var Re=e=>{let t=null,n=!1,r=!1,i=!1;return{async start(){let a=await Le({...e.vad,...e.constraints?{constraints:e.constraints}:{}});n||r?a.cancel():(t=a,i&&a.suspend(),a.on(`speechstart`,()=>e.onSpeaking?.(!0)),a.on(`level`,({level:t})=>e.onLevel?.(t)),a.on(`speechend`,t=>{e.onSpeaking?.(!1),e.onUtterance({pcm:t.samples,sampleRate:t.sampleRate,durationMs:t.durationMs,reason:t.reason})}))},suspend(){i=!0,t?.suspend(),e.onSpeaking?.(!1)},resume(){i=!1,t?.resume()},stop(){r=!0;let n=t;t=null,n?.stop().catch(t=>{e.onError?.(t instanceof Error?t:Error(String(t)))})},cancel(){n=!0,t?.cancel(),t=null}}};function ze(e){return m({model:e,createWorker:()=>new ae,loadSpeech:()=>c(()=>import(`./BbwIep6z.js`),__vite__mapDeps([0,1,2]),import.meta.url)})}var Be=[`material`,`glass`,`studio`,`smrt`,`happyvertical`],Ve=`@happyvertical/smrt-commerce:`,He={currency:[`Order`,`PurchaseOrder`,`WholesaleOrder`,`Estimate`,`Invoice`,`Agreement`].map(e=>({model:`${Ve}${e}`,field:`currency`})),taxRate:[`InvoiceLineItem`,`ContractLineItem`].map(e=>({model:`${Ve}${e}`,field:`taxRate`})),pricesIncludeTax:[`Invoice`,`Contract`].map(e=>({model:`${Ve}${e}`,field:`lineAmountType`})),taxRounding:[`Invoice`,`Contract`].map(e=>({model:`${Ve}${e}`,field:`taxRoundingScope`})),paymentTerms:[...[`Order`,`WholesaleOrder`,`Estimate`,`Invoice`,`Agreement`].map(e=>({model:`${Ve}${e}`,field:`terms`})),{model:`${Ve}Customer`,field:`paymentTerms`}]},Ue={id:`more`,label:`More`},We=/^@[^/]+\/(?:smrt-)?([^:]+):(.+)$/;function Ge(e,t){let n=e.models.find(e=>e.id===t);if(n)return{packageId:n.packageId,name:n.name};let r=We.exec(t);return r?{packageId:r[1],name:r[2]}:{packageId:`unknown`,name:t}}var Ke=(e,t,n)=>`item:${e}:${t}${n?`:${n}`:``}`,qe=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase()),Je=(e,t)=>qe(Ge(e,t).name);function Ye(e,t){let n=new Map(e.recipes.map(e=>[e.id,e])),r=new Map;for(let i of[...t.recipes].sort()){let t=n.get(i);if(!t)continue;let a=t.section??{id:t.group?.id??t.id,label:t.group?.label??t.label},o=`section:${a.id}`,s=r.get(o)??{id:o,label:a.label,items:[]};for(let n of t.nav){let{packageId:t,name:r}=Ge(e,n.model),i=Ke(t,r,n.key);s.items.some(e=>e.id===i)||s.items.push({id:i,label:n.label})}r.set(o,s)}let i=[...r.values()].filter(e=>e.items.length>0),a=new Set(e.models.filter(e=>e.exposed!==!1).map(e=>e.id)),o=t.features.filter(e=>a.has(e));return o.length&&i.push({id:`section:${Ue.id}`,label:Ue.label,items:o.map(t=>{let{packageId:n,name:r}=Ge(e,t);return{id:Ke(n,r),label:qe(r)}})}),i}var Xe=(e,t)=>{if(!t?.length)return e;let n=e=>{let n=t.indexOf(e);return n<0?2**53-1:n};return[...e].sort((e,t)=>n(e.id)-n(t.id))};function Ze(e,t){let n=t.layout,r=Ye(e,t).map(e=>({id:e.id,label:e.label,defaultLabel:e.label,custom:!1,hidden:!1,items:e.items.map(e=>({id:e.id,label:e.label,defaultLabel:e.label,hidden:!1}))}));for(let e of n?.customSections??[])r.some(t=>t.id===e.id)||r.push({id:e.id,label:e.label,defaultLabel:e.label,custom:!0,hidden:!1,items:[]});for(let[e,t]of Object.entries(n?.moved??{})){let n=r.find(e=>e.id===t);if(n)for(let t of r){let r=t.items.findIndex(t=>t.id===e);r>=0&&t!==n&&n.items.push(...t.items.splice(r,1))}}let i=new Set(n?.hidden??[]);for(let e of r){let t=n?.sections?.[e.id]?.label?.trim();t&&!e.custom&&(e.label=t),e.hidden=i.has(e.id),e.items=Xe(e.items,n?.itemOrder?.[e.id]);for(let t of e.items){let e=n?.items?.[t.id]?.label?.trim();e&&(t.label=e),t.hidden=i.has(t.id)}}return Xe(r.filter(e=>e.custom||e.items.length>0),n?.sectionOrder)}var j=(e,t)=>e.models.find(e=>e.id===t),Qe=e=>{let t={...e};for(let e of[`hidden`,`customSections`,`sectionOrder`])t[e]?.length||delete t[e];for(let e of[`sections`,`items`,`itemOrder`,`moved`,`panels`,`placements`])t[e]&&Object.keys(t[e]).length===0&&delete t[e];return Object.keys(t).length>1?t:void 0};function $e(e,t,n){let r=e?structuredClone(e):{version:1},i=n.trim();if(t.custom)return i?(r.customSections=r.customSections?.map(e=>e.id===t.id?{...e,label:i}:e),Qe(r)):e;let a={...r.sections??{}},o={...a[t.id]??{}};return!i||i===t.defaultLabel?delete o.label:o.label=i,Object.keys(o).length?a[t.id]=o:delete a[t.id],r.sections=a,Qe(r)}function et(e,t,n){let r=e?structuredClone(e):{version:1},i=n?.trim()??``,a={...r.items??{}},o={...a[t.id]??{}};return!i||i===t.defaultLabel?delete o.label:o.label=i,Object.keys(o).length?a[t.id]=o:delete a[t.id],r.items=a,Qe(r)}function tt(e,t,n){let r=e?structuredClone(e):{version:1},i=(r.hidden??[]).filter(e=>e!==t);return r.hidden=n?[...i,t]:i,Qe(r)}var nt=`https://s-m-r-t.dev/schemas/cookbook/v1.json`,rt=new Set([`basic`,`advanced`,`hidden`]),it=new Set([`api`,`mcp`,`cli`]),at=new Set([`light`,`dark`,`system`]),ot={borderRadius:[`none`,`sm`,`md`,`lg`,`xl`,`full`],density:[`comfortable`,`touch`],contrast:[`auto`,`standard`,`more`]},st=new Set([`header.start`,`header.center`,`header.end`,`footer.start`,`footer.center`,`footer.end`,`leftSidebar.header`,`leftSidebar.footer`,`rightSidebar.header`,`rightSidebar.footer`]),M=e=>typeof e==`object`&&!!e&&!Array.isArray(e),N=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`),ct=(e,t)=>M(e)&&!Object.hasOwn(e,`__proto__`)&&Object.values(e).every(t),lt=(e,t,n,r,i)=>{e.push({severity:t,code:n,path:r,message:i})},P=(e,t,n,r)=>lt(e,`error`,t,n,r),F=(e,t,n,r)=>lt(e,`warning`,t,n,r);function ut(e,t,n){if(!M(e))return P(n,`invalid_type`,t,`${t} must be an object`);for(let r of[`objectRef`,`fieldName`])(typeof e[r]!=`string`||!e[r])&&P(n,`invalid_value`,`${t}.${r}`,`${t}.${r} must be a non-empty string`);e.scopeType!==`app`&&P(n,`invalid_value`,`${t}.scopeType`,`${t}.scopeType must be "app"`);for(let r of[`defaultValue`,`help`,`label`]){let i=e[r];i!=null&&typeof i!=`string`&&P(n,`invalid_type`,`${t}.${r}`,`${t}.${r} must be a string or null`)}let r=e.visibility;r!=null&&!(typeof r==`string`&&rt.has(r))&&P(n,`invalid_value`,`${t}.visibility`,`${t}.visibility must be basic, advanced or hidden`);let i=e.displayOrder;i!=null&&!(typeof i==`number`&&Number.isFinite(i))&&P(n,`invalid_value`,`${t}.displayOrder`,`${t}.displayOrder must be a finite number`),e.locked!=null&&typeof e.locked!=`boolean`&&P(n,`invalid_type`,`${t}.locked`,`${t}.locked must be a boolean`)}function dt(e,t){if(!M(e)||e.version!==1)return P(t,`invalid_value`,`layout`,`layout must be an object with version 1`);for(let n of[`sectionOrder`,`hidden`])e[n]!==void 0&&!N(e[n])&&P(t,`invalid_type`,`layout.${n}`,`layout.${n} must be a list of strings`);for(let n of[`itemOrder`,`moved`,`placements`]){let r=e[n];r!==void 0&&((n===`itemOrder`?ct(r,N):ct(r,e=>typeof e==`string`))||P(t,`invalid_type`,`layout.${n}`,n===`itemOrder`?`layout.itemOrder must map ids to lists of strings`:`layout.${n} must map ids to strings`))}if(M(e.placements))for(let[n,r]of Object.entries(e.placements))typeof r==`string`&&!st.has(r)&&P(t,`unknown_layout_slot`,`layout.placements.${n}`,`Unknown shell slot "${r}".`);for(let n of[`sections`,`items`,`panels`])e[n]!==void 0&&!ct(e[n],e=>M(e))&&P(t,`invalid_type`,`layout.${n}`,`layout.${n} must map ids to objects`);let n=e.customSections;n!==void 0&&!(Array.isArray(n)&&n.every(e=>M(e)&&typeof e.id==`string`&&typeof e.label==`string`))&&P(t,`invalid_type`,`layout.customSections`,`layout.customSections must be a list of { id, label }`)}function ft(e,t){if(!M(e))return P(t,`invalid_type`,`theme`,`theme must be an object`);e.preset!==void 0&&typeof e.preset!=`string`&&P(t,`invalid_type`,`theme.preset`,`theme.preset must be a string`),e.fontFamily!==void 0&&(typeof e.fontFamily!=`string`||!e.fontFamily)&&P(t,`invalid_value`,`theme.fontFamily`,`theme.fontFamily must be a non-empty string`),e.customCss!==void 0&&(typeof e.customCss==`string`?Array.from(e.customCss).length>65536&&P(t,`invalid_value`,`theme.customCss`,`theme.customCss must be at most 65,536 characters`):P(t,`invalid_type`,`theme.customCss`,`theme.customCss must be a string`)),e.colorScheme!==void 0&&!(typeof e.colorScheme==`string`&&at.has(e.colorScheme))&&P(t,`invalid_value`,`theme.colorScheme`,`theme.colorScheme must be light, dark or system`);for(let n of[`borderRadius`,`density`,`contrast`]){let r=ot[n],i=e[n];i!==void 0&&!(typeof i==`string`&&r.includes(i))&&P(t,`invalid_value`,`theme.${n}`,`theme.${n} must be one of ${r.join(`, `)}`)}let n=e.custom;n!==void 0&&(!M(n)||typeof n.primary!=`string`?P(t,`invalid_value`,`theme.custom`,`theme.custom must be an object with a string primary`):/^#[0-9a-fA-F]{6}$/.test(n.primary)?n.fontFamily!==void 0&&typeof n.fontFamily!=`string`&&P(t,`invalid_type`,`theme.custom.fontFamily`,`theme.custom.fontFamily must be a string`):P(t,`invalid_value`,`theme.custom.primary`,`theme.custom.primary must be a hex colour like #c2410c`))}var pt=/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,95}$/,mt=/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/,ht=/^[a-z][a-z0-9-]{0,31}$/,gt=e=>e===null||typeof e==`string`||typeof e==`number`&&Number.isFinite(e)||typeof e==`boolean`;function _t(e,t,n){return M(e)?[typeof e.id==`string`&&mt.test(e.id),typeof e.type==`string`&&ht.test(e.type),typeof e.span==`number`&&Number.isInteger(e.span)&&e.span>=1&&e.span<=4,M(e.options)&&Object.values(e.options).every(gt),e.version===void 0||typeof e.version==`number`&&Number.isInteger(e.version)&&e.version>=1].every(Boolean)?e:(F(n,`malformed_overview_widget`,t,`${t} was dropped because it is not a valid overview widget`),null):(F(n,`malformed_overview_widget`,t,`${t} was dropped`),null)}function vt(e,t,n){return M(e)?(e.span===void 0||typeof e.span==`number`&&Number.isInteger(e.span)&&e.span>=1&&e.span<=4)&&(e.options===void 0||M(e.options)&&Object.values(e.options).every(gt))&&(e.version===void 0||typeof e.version==`number`&&Number.isInteger(e.version)&&e.version>=1)?e:(F(n,`malformed_overview_change`,t,`${t} was dropped because it is not a valid widget change`),null):(F(n,`malformed_overview_change`,t,`${t} was dropped`),null)}function yt(e,t,n){if(!M(e)||e.version!==1)return F(n,`malformed_overview`,t,`${t} was dropped because it must be an object with version 1`),null;let r={...e,version:1};for(let i of[`order`,`removed`])e[i]!==void 0&&!N(e[i])?(F(n,`malformed_overview_list`,`${t}.${i}`,`${t}.${i} was dropped because it must be a list of strings`),delete r[i]):e[i]!==void 0&&(r[i]=[...new Set(e[i])]);if(e.added!==void 0){if(!Array.isArray(e.added))F(n,`malformed_overview_widgets`,`${t}.added`,`${t}.added was dropped because it must be a list of widgets`),delete r.added;else{let i=e.added.flatMap((e,r)=>{let i=_t(e,`${t}.added[${r}]`,n);return i?[i]:[]});i.length?r.added=i:delete r.added}}if(e.changed!==void 0){if(!M(e.changed)||Object.hasOwn(e.changed,`__proto__`))F(n,`malformed_overview_changes`,`${t}.changed`,`${t}.changed was dropped because it must map widget ids to objects`),delete r.changed;else{let i={};for(let[r,a]of Object.entries(e.changed)){if(!mt.test(r)){F(n,`malformed_overview_change`,`${t}.changed.${r}`,`${t}.changed.${r} was dropped because its widget id is invalid`);continue}let e=vt(a,`${t}.changed.${r}`,n);e&&(i[r]=e)}Object.keys(i).length?r.changed=i:delete r.changed}}return r}function bt(e,t={}){let n=[];if(!M(e))return P(n,`invalid_type`,``,`expected a JSON object`),{ok:!1,errors:[`expected a JSON object`],diagnostics:n};let{$schema:r,version:i}=e;r!==void 0&&r!==`https://s-m-r-t.dev/schemas/cookbook/v1.json`&&r!==`https://s-m-r-t.dev/schemas/blueprint/v1.json`&&P(n,`invalid_schema`,`$schema`,`$schema must be ${nt}`),i===void 0?P(n,`missing_field`,`version`,`version is required`):typeof i!=`number`||!Number.isInteger(i)?P(n,`invalid_type`,`version`,`version must be a whole number`):i>1?P(n,`unsupported_version`,`version`,`version ${i} is newer than this reader understands (1)`):i!==1&&P(n,`unsupported_version`,`version`,`version ${i} is not supported`),r===`https://s-m-r-t.dev/schemas/blueprint/v1.json`&&F(n,`migrated_schema`,`$schema`,`$schema uses the legacy blueprint URL; migrated`);for(let t of[`name`,`description`])e[t]!==void 0&&typeof e[t]!=`string`&&P(n,`invalid_type`,t,`${t} must be a string`);let a=[];if(!N(e.recipes))P(n,`invalid_type`,`recipes`,`recipes must be a list of recipe ids`);else if(a=[...new Set(e.recipes)].sort(),t.recipes){let r=new Set(t.recipes);for(let t of a)r.has(t)||P(n,`unknown_recipe`,`recipes[${e.recipes.indexOf(t)}]`,`recipes: unknown recipe "${t}"`)}let o=[];e.features!==void 0&&(N(e.features)?(o=[...new Set(e.features)].sort(),o.length!==e.features.length&&F(n,`duplicate_value`,`features`,`features listed a model more than once; deduplicated`)):P(n,`invalid_type`,`features`,`features must be a list of model names`));let s=[];if(!Array.isArray(e.policies))P(n,`invalid_type`,`policies`,`policies must be a list`);else for(let[t,r]of e.policies.entries())ut(r,`policies[${t}]`,n),s.push(r);if(e.exposure!==void 0&&(ct(e.exposure,e=>N(e)&&e.every(e=>it.has(e)))||P(n,`invalid_value`,`exposure`,`exposure must map model names to lists of api, mcp or cli`)),e.layout!==void 0&&dt(e.layout,n),e.theme!==void 0&&ft(e.theme,n),M(e.theme)&&typeof e.theme.preset==`string`){let r=t.themePresets?new Set(t.themePresets):void 0;r&&!r.has(e.theme.preset)&&P(n,`unknown_theme_preset`,`theme.preset`,`Unknown theme preset "${e.theme.preset}".`)}if(M(e.layout)&&e.layout.version===1&&t.layout){let r=t.layout.sections?new Set(t.layout.sections):void 0,i=t.layout.items?new Set(t.layout.items):void 0,a=t.layout.placementItems?new Set(t.layout.placementItems):void 0;if(r&&Array.isArray(e.layout.customSections))for(let t of e.layout.customSections)M(t)&&typeof t.id==`string`&&r.add(t.id);let o=(e,t)=>t===`section`?r?.has(e)!==!1:t===`item`?i?.has(e)!==!1:r?.has(e)===!0||i?.has(e)===!0||!r&&!i,s=(e,t,r)=>{typeof e==`string`&&!o(e,r)&&P(n,`unknown_layout_id`,t,`Unknown layout ${r===`either`?`section or item`:r} "${e}".`)};if(N(e.layout.sectionOrder)&&e.layout.sectionOrder.forEach((e,t)=>{s(e,`layout.sectionOrder[${t}]`,`section`)}),N(e.layout.hidden)&&e.layout.hidden.forEach((e,t)=>{s(e,`layout.hidden[${t}]`,`either`)}),M(e.layout.itemOrder))for(let[t,n]of Object.entries(e.layout.itemOrder))s(t,`layout.itemOrder.${t}`,`section`),N(n)&&n.forEach((e,n)=>{s(e,`layout.itemOrder.${t}[${n}]`,`item`)});if(M(e.layout.moved))for(let[t,n]of Object.entries(e.layout.moved))s(t,`layout.moved.${t}`,`item`),s(n,`layout.moved.${t}`,`section`);for(let t of[`sections`,`items`])if(M(e.layout[t]))for(let n of Object.keys(e.layout[t]))s(n,`layout.${t}.${n}`,t===`sections`?`section`:`item`);if(M(e.layout.placements))for(let t of Object.keys(e.layout.placements))a&&!a.has(t)&&P(n,`unknown_layout_id`,`layout.placements.${t}`,`Unknown layout placement item "${t}".`)}let c={};if(e.overviews!==void 0){if(!M(e.overviews)||Object.hasOwn(e.overviews,`__proto__`))P(n,`invalid_type`,`overviews`,`overviews must map overview ids to overrides`);else{let r=t.overviewIds?new Set(t.overviewIds):void 0;for(let[i,a]of Object.entries(e.overviews)){let e=`overviews.${i}`;if(!pt.test(i)){F(n,`invalid_overview_id`,e,`${e} was dropped because its overview id is invalid`);continue}if(r&&!r.has(i)){F(n,`unknown_overview`,e,`Unknown overview "${i}" was dropped.`);continue}let o=yt(a,e,n);if(!o)continue;if(!t.validateOverview){c[i]=o;continue}let s;try{s=t.validateOverview(i,o)}catch{F(n,`overview_validation_failed`,e,`Overview "${i}" was dropped because its host validator failed.`);continue}for(let t of s.diagnostics??[])F(n,t.code,t.path||e,t.message);!s.ok&&s.diagnostics.length===0&&F(n,`overview_rejected`,e,`Overview "${i}" was rejected by its host validator and dropped.`),s.ok&&s.override&&(c[i]=s.override)}}}let l=n.filter(e=>e.severity===`error`).map(e=>e.message);if(l.length)return{ok:!1,errors:l,diagnostics:n};let u={...e,$schema:nt,version:1,recipes:a,features:o,policies:s};return e.exposure!==void 0&&(u.exposure=e.exposure),e.layout!==void 0&&(u.layout=e.layout),e.theme!==void 0&&(u.theme=e.theme),delete u.overviews,Object.keys(c).length&&(u.overviews=c),{ok:!0,cookbook:u,warnings:n.filter(e=>e.severity===`warning`).map(e=>e.message),diagnostics:n}}var I=e=>e===void 0?e:structuredClone(e),xt=(e,t)=>JSON.stringify(e??null)===JSON.stringify(t??null),St=()=>({$schema:nt,version:1,recipes:[],features:[],policies:[]});function Ct(e){return!e.recipes.length&&!e.features.length&&!e.policies.length&&!Object.keys(e.exposure??{}).length&&!e.layout&&!e.theme&&!Object.keys(e.overviews??{}).length}var wt=e=>[...new Set(e)].sort();function Tt(e){let t=new Set([`$schema`,`version`,`name`,`description`,`recipes`,`features`,`policies`,`exposure`,`layout`,`theme`,`overviews`]),n={$schema:nt,version:1,...e.name?{name:e.name}:{},...e.description?{description:e.description}:{},recipes:wt(e.recipes),features:wt(e.features),policies:[...e.policies].sort((e,t)=>e.objectRef.localeCompare(t.objectRef)||e.fieldName.localeCompare(t.fieldName)).map(e=>({...e}))},r=Object.fromEntries(Object.keys(e.exposure??{}).sort().filter(t=>e.exposure?.[t]?.length).map(t=>[t,[...e.exposure?.[t]??[]].sort()]));Object.keys(r).length&&(n.exposure=r),e.layout&&(n.layout=I(e.layout));let i=Kt(e.theme);i&&(n.theme=i);let a=Object.entries(e.overviews??{}).sort(([e],[t])=>e<t?-1:+(e>t));a.length&&(n.overviews=Object.fromEntries(a.map(([e,t])=>[e,I(t)])));for(let[r,i]of Object.entries(e))t.has(r)||(n[r]=I(i));return n}var L=e=>new Map(e.recipes.map(e=>[e.id,e]));function Et(e,t){let n=new Set,r=e=>{let i=t.get(e);if(i&&!n.has(e)){n.add(e);for(let e of i.requires)r(e)}};for(let t of e)r(t);let i=!0;for(;i;){i=!1;for(let e of[...n])for(let a of t.get(e)?.requiresAny??[]){if(a.some(e=>n.has(e)))continue;let e=a.find(e=>t.has(e));e&&(r(e),i=!0)}}return wt(n)}function Dt(e,t){let n=L(e);return new Set([...t.recipes.flatMap(e=>n.get(e)?.models??[]),...t.features])}function Ot(e){return e.settingTargets??He}function kt(e,t){return Object.values(Ot(e)).some(e=>e.some(e=>e.model===t.objectRef&&e.field===t.fieldName))}function At(e,t){let n=Dt(e,t),r={...t,policies:t.policies.filter(t=>n.has(t.objectRef)||kt(e,t))};if(t.exposure){let e=Object.fromEntries(Object.entries(t.exposure).filter(([e])=>n.has(e)));Object.keys(e).length?r.exposure=e:delete r.exposure}return r}var jt=(e,t)=>{let n=L(e);return t.recipes.filter(e=>n.has(e))},Mt=(e,t)=>{let n=L(e);return t.recipes.filter(e=>!n.has(e))};function Nt(e,t){let n=new Set(e),r=new Set(t);return{added:t.filter(e=>!n.has(e)),removed:e.filter(e=>!r.has(e))}}function Pt(e,t,n){let r=L(e),i=jt(e,t),a=Et([...i,...n],r);return{doc:{...t,recipes:wt([...a,...Mt(e,t)])},changes:{...Nt(i,a),kept:[]}}}function Ft(e,t,n){let r=L(e),i=jt(e,t),a=new Set(n),o=Et(i.filter(e=>!a.has(e)),r),s=At(e,{...t,recipes:wt([...o,...Mt(e,t)])}),{added:c,removed:l}=Nt(i,o);return{doc:s,changes:{added:c,removed:l,kept:n.filter(e=>o.includes(e)&&i.includes(e))}}}function It(e,t,n,r){let i=new Set(t.features);for(let e of n)r?i.add(e):i.delete(e);let a=[...i].sort(),o={...t,features:a};return r||(o=At(e,o)),{doc:o,changes:{...Nt(t.features,a),kept:[]}}}var Lt=(e,t)=>({added:[...e.added,...t.added],removed:[...e.removed,...t.removed],kept:[...e.kept,...t.kept]}),Rt={currency:`USD`,taxRate:0,paymentTerms:``,pricesIncludeTax:!1,taxRounding:`line`},zt=[`currency`,`taxRate`,`paymentTerms`,`pricesIncludeTax`,`taxRounding`];function Bt(e){if(e?.defaultValue!==void 0&&e.defaultValue!==null)try{return JSON.parse(e.defaultValue)}catch{return}}var Vt=(e,t,n)=>e.find(e=>e.scopeType===`app`&&e.objectRef===t&&e.fieldName===n);function Ht(e,t){let n=Ot(e),r={...Rt},i=(e,r)=>{for(let{model:i,field:a}of n[e]){let e=Bt(Vt(t.policies,i,a));if(typeof e===r)return e}},a=i(`currency`,`string`),o=i(`taxRate`,`number`),s=i(`paymentTerms`,`string`),c=i(`pricesIncludeTax`,`string`),l=i(`taxRounding`,`string`);return typeof a==`string`&&(r.currency=a),typeof o==`number`&&(r.taxRate=o),typeof s==`string`&&(r.paymentTerms=s),(c===`inclusive`||c===`exclusive`)&&(r.pricesIncludeTax=c===`inclusive`),(l===`line`||l===`document`)&&(r.taxRounding=l),r}var Ut=e=>e==null||e===``;function Wt(e,t,n,r){let i=L(e);for(let e of t.recipes){let t=i.get(e)?.options?.[n]?.fields?.[r];if(t&&`default`in t)return t.default}return j(e,n)?.fields?.find(e=>e.name===r)?.default}function Gt(e,t,n){let r=Ot(e),i=t.policies.map(e=>({...e}));for(let a of zt){let o=n[a],s=a===`paymentTerms`?String(o).trim():a===`currency`?String(o).trim().toUpperCase():a===`pricesIncludeTax`?o?`inclusive`:`exclusive`:o;for(let{model:n,field:o}of r[a]){let r=Wt(e,t,n,o),c=!Ut(s)&&!(!Ut(r)&&r===s)&&!(Ut(r)&&a===`taxRate`&&s===0),l=Vt(i,n,o);if(c){let e=JSON.stringify(s);l?l.defaultValue=e:i.push({objectRef:n,fieldName:o,scopeType:`app`,defaultValue:e})}else l&&(delete l.defaultValue,Object.keys(l).length<=3&&(i=i.filter(e=>e!==l)))}}return{...t,policies:i}}function Kt(e){if(!e)return;let t={};return e.preset&&(t.preset=e.preset),e.colorScheme&&(t.colorScheme=e.colorScheme),e.borderRadius&&(t.borderRadius=e.borderRadius),e.density&&(t.density=e.density),e.contrast&&(t.contrast=e.contrast),e.fontFamily&&(t.fontFamily=e.fontFamily),e.custom&&(t.custom={...e.custom}),e.customCss&&(t.customCss=e.customCss),Object.keys(t).length?t:void 0}function qt(e){let t=e?.colorScheme??`system`,n=e?.custom?`brand colour ${e.custom.primary}`:e?.preset??`smrt`;return t===`system`?n:`${n}, ${t}`}function Jt(e,t){let n={...e.theme??{}};t.preset&&(n.preset=t.preset,delete n.custom),t.primary&&(n.custom={primary:t.primary.toLowerCase(),...e.theme?.custom?.fontFamily?{fontFamily:e.theme.custom.fontFamily}:{}}),t.colorScheme&&(n.colorScheme=t.colorScheme),t.borderRadius&&(n.borderRadius=t.borderRadius),t.density&&(n.density=t.density),t.contrast&&(n.contrast=t.contrast),t.fontFamily===null?(delete n.fontFamily,n.custom?.fontFamily&&(n.custom={primary:n.custom.primary})):t.fontFamily!==void 0&&(n.fontFamily=t.fontFamily);let r=Kt(n),i={...e};return r?i.theme=r:delete i.theme,i}function Yt(e,t){let n=[],r=(e,t,r,i)=>n.push({severity:e,code:t,path:r,message:i}),i=bt(t);if(!i.ok){for(let e of i.diagnostics.filter(e=>e.severity===`error`))r(`error`,`invalid_document`,e.path,e.message);return n}for(let e of i.diagnostics)r(e.severity,e.code===`migrated_schema`?`migrated`:e.code,e.path,e.message);let a=i.cookbook,o=L(e),s=Ze(e,{...a,layout:void 0}),c=bt(a,{themePresets:e.themePresets??Be,layout:{sections:s.map(e=>e.id),items:s.flatMap(e=>e.items.map(e=>e.id)),...e.placementItems?{placementItems:e.placementItems}:{}},overviewIds:[...s.map(e=>e.id),...(a.layout?.customSections??[]).map(e=>e.id)]});for(let e of c.diagnostics)(e.code===`unknown_theme_preset`||e.code===`unknown_layout_id`||e.code===`unknown_overview`)&&r(e.code===`unknown_layout_id`&&!e.path.startsWith(`layout.placements.`)?`warning`:e.severity,e.code===`unknown_theme_preset`?`unknown_preset`:e.code,e.path,e.message);for(let[e,t]of a.recipes.entries())o.has(t)||r(`error`,`unknown_recipe`,`recipes[${e}]`,`Unknown recipe "${t}".`);let l=new Set(Et(a.recipes,o));for(let e of l)a.recipes.includes(e)||r(`error`,`missing_requirement`,`recipes`,`A recipe needs "${e}", which is not listed.`);for(let[t,n]of a.features.entries()){let i=j(e,n);i?i.exposed===!1&&r(`error`,`model_not_exposed`,`features[${t}]`,`${n} cannot be added as a feature.`):r(`error`,`unknown_model`,`features[${t}]`,`Unknown model "${n}".`)}let u=Dt(e,a);for(let[t,n]of a.policies.entries()){let i=`policies[${t}]`,a=j(e,n.objectRef);a?(a.fields&&!a.fields.some(e=>e.name===n.fieldName&&!e.system)&&r(`error`,`unknown_field`,`${i}.fieldName`,`${a.name} has no field "${n.fieldName}".`),!u.has(n.objectRef)&&!kt(e,n)&&r(`warning`,`policy_not_covered`,i,`${a.name} is not in the app, so this row has no effect.`)):r(`error`,`unknown_model`,`${i}.objectRef`,`Unknown model "${n.objectRef}".`)}for(let t of Object.keys(a.exposure??{}))j(e,t)||r(`error`,`unknown_model`,`exposure.${t}`,`Unknown model "${t}".`);return n}var R=(e,t,n={})=>({ok:!1,error:{code:e,message:t,...n}}),z=(e,t=``,n={})=>({ok:!0,state:e,summary:t,...n}),Xt=`This replaces the recipes, options, menu and look. Send replace: true to confirm.`,B=e=>e.join(`, `);function Zt(e){return`${(e??``).normalize(`NFD`).replace(/\p{M}/gu,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`my-app`}.cookbook.json`}var Qt=e=>`${JSON.stringify(e,null,2)}\n`;function $t(e,t){let n=new Map(e.recipes.map(e=>[e.id,e])),r=t.recipes.filter(e=>n.has(e)),i=t.recipes.filter(e=>!n.has(e));return Tt(At(e,{...I(t),recipes:[...Et(r,n),...i]}))}function en(e,t){return t?e.cookbooks?.find(e=>e.id===t)?.name:void 0}var tn=(e,t)=>{let n=t=>e.recipes.find(e=>e.id===t)?.label??t;return[t.added.length?`Added ${B(t.added.map(n))}.`:``,t.removed.length?`Removed ${B(t.removed.map(n))}.`:``,t.kept.length?`Kept ${B(t.kept.map(n))} (needed).`:``].filter(Boolean).join(` `)},nn=(e,t)=>[t.added.length?`Added ${B(t.added.map(t=>Je(e,t)))}.`:``,t.removed.length?`Removed ${B(t.removed.map(t=>Je(e,t)))}.`:``].filter(Boolean).join(` `),rn=e=>`${Number((e*100).toFixed(4))}%`,V=(e,t)=>({...e,doc:Tt(t)});function an(e,t){let n=Ze(e,t);return{sections:n,section:e=>n.find(t=>t.id===e),item:e=>n.flatMap(e=>e.items).find(t=>t.id===e)}}var on=(e,t)=>{let n={...e};return t?n.layout=t:delete n.layout,n},sn={add_recipes(e,t,{ids:n}){let r=n.filter(t=>!e.recipes.some(e=>e.id===t));if(r.length)return R(`not_found`,`No such recipe: ${B(r)}.`,{path:`input.ids`});let{doc:i,changes:a}=Pt(e,t.doc,n);return z(V(t,i),tn(e,a),{changes:a})},remove_recipes(e,t,{ids:n}){let{doc:r,changes:i}=Ft(e,t.doc,n);return z(V(t,r),tn(e,i),{changes:i})},add_features(e,t,{ids:n}){let r=n.filter(t=>!j(e,t)?.exposed);if(r.length)return R(`not_found`,`No such model to add: ${B(r)}.`,{path:`input.ids`});let{doc:i,changes:a}=It(e,t.doc,n,!0);return z(V(t,i),nn(e,a),{changes:a})},remove_features(e,t,{ids:n}){let{doc:r,changes:i}=It(e,t.doc,n,!1);return z(V(t,r),nn(e,i),{changes:i})},add_cookbook(e,t,{id:n}){let r=e.cookbooks?.find(e=>e.id===n);if(!r)return R(`not_found`,`No cookbook "${n}".`,{path:`input.id`});let i=Pt(e,t.doc,r.document.recipes),a=It(e,i.doc,r.document.features.filter(t=>j(e,t)?.exposed),!0),o=Lt(i.changes,a.changes);return z(V(t,a.doc),o.added.length?`Added the ${r.name} cookbook.`:``,{changes:o})},remove_cookbook(e,t,{id:n}){let r=e.cookbooks?.find(e=>e.id===n);if(!r)return R(`not_found`,`No cookbook "${n}".`,{path:`input.id`});let i=Ft(e,t.doc,r.document.recipes),a=It(e,i.doc,r.document.features,!1),o=Lt(i.changes,a.changes);return z(V(t,a.doc),[tn(e,i.changes),nn(e,a.changes)].filter(Boolean).join(` `),{changes:o})},apply_cookbook(e,t,{id:n,replace:r}){let i=e.cookbooks?.find(e=>e.id===n);return i?!r&&!Ct(t.doc)?R(`confirmation_required`,Xt):z({doc:$t(e,i.document),applied:n},`${i.name} set up.`):R(`not_found`,`No cookbook "${n}".`,{path:`input.id`})},import_cookbook(e,t,{document:n,replace:r}){let i=bt(n);if(!i.ok)return R(`invalid_input`,i.errors[0]??`Not a cookbook.`,{path:`input.document`,details:{errors:i.errors}});if(!r&&!Ct(t.doc))return R(`confirmation_required`,Xt);let a=i.cookbook.recipes.length;return z({doc:$t(e,i.cookbook),applied:null},`Imported ${a} ${a===1?`recipe`:`recipes`}.`,i.warnings.length?{warnings:i.warnings}:{})},set_settings(e,t,n){let r=Ht(e,t.doc),i={...r},a=[];if(n.currency!==void 0){let t=n.currency.trim().toUpperCase();if(e.currencies&&!e.currencies.includes(t))return R(`invalid_input`,`${t} is not a known currency.`,{path:`input.currency`});if(!/^[A-Z]{3}$/.test(t))return R(`invalid_input`,`currency must be a three-letter code.`,{path:`input.currency`});t!==r.currency&&(i.currency=t,a.push(`currency ${t}`))}if(n.taxRate!==void 0){let e=Number((n.taxRate/100).toFixed(6));e!==r.taxRate&&(i.taxRate=e,a.push(`tax ${rn(e)}`))}if(n.paymentTerms!==void 0){let e=[...n.paymentTerms].map(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127?` `:e).join(``).trim();if(!e)return R(`invalid_input`,`paymentTerms must not be empty.`,{path:`input.paymentTerms`});e!==r.paymentTerms&&(i.paymentTerms=e,a.push(`terms ${e}`))}if(n.pricesIncludeTax!==void 0&&n.pricesIncludeTax!==r.pricesIncludeTax&&(i.pricesIncludeTax=n.pricesIncludeTax,a.push(n.pricesIncludeTax?`prices include tax`:`prices exclude tax`)),n.taxRounding!==void 0&&n.taxRounding!==r.taxRounding&&(i.taxRounding=n.taxRounding,a.push(`${n.taxRounding} tax rounding`)),!a.length)return z(t);let o=a.join(`, `);return z(V(t,Gt(e,t.doc,i)),`${o[0].toUpperCase()}${o.slice(1)}.`)},set_policy(e,t,n){let r=j(e,n.model);if(!r)return R(`not_found`,`No such model: ${n.model}.`,{path:`input.model`});if(r.fields){let e=r.fields.find(e=>e.name===n.field);if(!e||e.system)return R(`not_found`,`${r.name} has no field ${n.field}.`,{path:`input.field`})}if(!Dt(e,t.doc).has(r.id))return R(`not_found`,`${qe(r.name)} is not in the app yet; add its recipe or feature first.`,{path:`input.model`});if(t.doc.recipes.some(t=>e.recipes.find(e=>e.id===t)?.options?.[r.id]?.fields?.[n.field]?.locked))return R(`failed`,`${n.field} is locked by its recipe.`,{path:`input.field`});let i=t.doc.policies.map(e=>({...e})),a=i.find(e=>e.objectRef===r.id&&e.fieldName===n.field),o=a??{objectRef:r.id,fieldName:n.field,scopeType:`app`},s=JSON.stringify(o);for(let e of[`visibility`,`label`,`help`]){let t=n[e];t!==void 0&&(t===null?delete o[e]:o[e]=t)}if(n.defaultValue!==void 0){if(n.defaultValue===null)delete o.defaultValue;else{let e=JSON.stringify(n.defaultValue);if(e===void 0)return R(`invalid_input`,`defaultValue is not a JSON value.`,{path:`input.defaultValue`});o.defaultValue=e}}let c=Object.keys(o).length<=3;if(JSON.stringify(o)===s||c&&!a)return z(t);let l=i.filter(e=>e!==a);return z(V(t,{...t.doc,policies:c?l:[...l,o]}),`Updated ${qe(r.name)} ${n.field}.`)},set_theme(e,t,n){let r=Jt(t.doc,n);return JSON.stringify(Tt(r).theme??null)===JSON.stringify(t.doc.theme??null)?z(t):z(V(t,r),`Theme: ${qt(Tt(r).theme)}.`)},reset_theme(e,t){if(!t.doc.theme)return z(t);let n={...t.doc};return delete n.theme,z(V(t,n),`Theme: default.`)},set_name(e,t,n){let r={...t.doc};for(let e of[`name`,`description`]){let t=n[e];if(t===void 0)continue;let i=t?.trim();i?r[e]=i:delete r[e]}return JSON.stringify(Tt(r))===JSON.stringify(t.doc)?z(t):z(V(t,r),n.name?`Named the app ${n.name.trim()}.`:`Updated the app details.`)},rename_section(e,t,{id:n,label:r}){let i=an(e,t.doc).section(n);if(!i)return R(`not_found`,`No menu section "${n}".`,{path:`input.id`});let a=$e(t.doc.layout,i,r);return JSON.stringify(a??null)===JSON.stringify(t.doc.layout??null)?z(t):z(V(t,on(t.doc,a)),`Renamed the section to ${r.trim()}.`)},rename_item(e,t,{id:n,label:r}){let i=an(e,t.doc).item(n);if(!i)return R(`not_found`,`No menu entry "${n}".`,{path:`input.id`});let a=et(t.doc.layout,i,r);return JSON.stringify(a??null)===JSON.stringify(t.doc.layout??null)?z(t):z(V(t,on(t.doc,a)),r?`Renamed the entry to ${r.trim()}.`:`Entry name restored.`)},hide(e,t,{id:n}){let r=an(e,t.doc);return r.section(n)??r.item(n)?t.doc.layout?.hidden?.includes(n)?z(t):z(V(t,on(t.doc,tt(t.doc.layout,n,!0))),`Hidden.`):R(`not_found`,`No menu section or entry "${n}".`,{path:`input.id`})},show(e,t,{id:n}){let r=an(e,t.doc);return!r.section(n)&&!r.item(n)?R(`not_found`,`No menu section or entry "${n}".`,{path:`input.id`}):t.doc.layout?.hidden?.includes(n)?z(V(t,on(t.doc,tt(t.doc.layout,n,!1))),`Shown.`):z(t)},validate(e,t){let n=Yt(e,t.doc);return z(t,``,{data:{ok:!n.some(e=>e.severity===`error`),diagnostics:n}})},export_cookbook(e,t,{name:n}){return z(t,``,{data:{fileName:Zt(n??t.doc.name??en(e,t.applied)),text:Qt(t.doc),cookbook:I(t.doc)}})}};function cn(e,t,n,r){let i=sn[n];return i?i(e,t,r):R(`unknown_command`,`No command "${n}".`)}var ln=(e,t)=>({type:`array`,description:e,minItems:1,maxItems:50,items:t?.length?{type:`string`,enum:[...t]}:{type:`string`,minLength:1}}),un=(e,t={})=>({type:`string`,description:e,minLength:1,maxLength:200,...t}),H=(e,t=[])=>({type:`object`,properties:e,...t.length?{required:t}:{},additionalProperties:!1});function dn(e){let t=e.recipes.map(e=>e.id),n=(e.cookbooks??[]).map(e=>e.id),r=e.themePresets??Be,i=e=>({type:`string`,description:e,...n.length?{enum:[...n]}:{minLength:1}}),a=e=>un(`The id of ${e}, as the plan snapshot's "sections" lists it.`),o={type:`boolean`,description:`Confirm replacing what is there.`};return[{name:`add_recipes`,description:`Switch recipes on. Recipes they require come along. Returns what was added.`,inputSchema:H({ids:ln(`Recipe ids to add.`,t)},[`ids`])},{name:`remove_recipes`,description:`Switch recipes off. A recipe another one needs is kept and reported.`,inputSchema:H({ids:ln(`Recipe ids to remove.`,t)},[`ids`])},{name:`add_features`,description:"Add single models no recipe covers, by qualified name (`@scope/pkg:Class`).",inputSchema:H({ids:ln(`Qualified model names to add.`)},[`ids`])},{name:`remove_features`,description:`Remove single models added with add_features.`,inputSchema:H({ids:ln(`Qualified model names to remove.`)},[`ids`])},{name:`add_cookbook`,description:`Add the recipes and features of a ready-made cookbook to the current app. Nothing is replaced.`,inputSchema:H({id:i(`The cookbook to add.`)},[`id`])},{name:`remove_cookbook`,description:`Remove the recipes and features a ready-made cookbook adds. Ones another recipe needs are kept.`,inputSchema:H({id:i(`The cookbook to remove.`)},[`id`])},{name:`apply_cookbook`,description:`Select a ready-made cookbook: replace the whole app (recipes, options, menu, theme) with it. When the app has anything in it, replace must be true.`,inputSchema:H({id:i(`The cookbook to set up.`),replace:o},[`id`])},{name:`import_cookbook`,description:`Replace the whole app with a cookbook document (version 1). Checked strictly; nothing is applied if it is invalid. When the app has anything in it, replace must be true.`,inputSchema:H({document:{type:`object`,description:`A cookbook document, version 1.`},replace:o},[`document`])},{name:`set_settings`,description:`Change app settings: currency, default tax rate (percent), default payment terms. Applies to new records only.`,inputSchema:H({currency:e.currencies?.length?{type:`string`,description:`ISO 4217 code, e.g. CAD.`,enum:[...e.currencies]}:{type:`string`,description:`ISO 4217 code, e.g. CAD.`,pattern:`^[A-Z]{3}$`},taxRate:{type:`number`,description:`Default tax rate in percent, 0 to 100.`,minimum:0,maximum:100},paymentTerms:{type:`string`,description:`Default payment terms, e.g. "Net 30".`,minLength:1,maxLength:40},pricesIncludeTax:{type:`boolean`,description:`Whether new document prices include tax.`},taxRounding:{enum:[`line`,`document`],description:`Whether tax rounds per line or per document.`}})},{name:`set_policy`,description:`Set one field's policy: default value, visibility, label or help. The model must be covered by a recipe or feature that is on. null clears a part.`,inputSchema:H({model:un(`Qualified model name, e.g. @happyvertical/smrt-commerce:Order.`),field:un(`The model field name.`),defaultValue:{description:`The default as a JSON value (a string, number or boolean). null clears it.`},visibility:{enum:[`basic`,`advanced`,`hidden`,null],description:`Whether the field shows in forms and lists.`},label:{type:[`string`,`null`],description:`A different label.`,maxLength:120},help:{type:[`string`,`null`],description:`Help text under the field.`,maxLength:400}},[`model`,`field`])},{name:`set_theme`,description:`Change the look: a preset, a brand colour, light or dark. A preset replaces a brand colour.`,inputSchema:H({preset:{enum:[...r],description:`A built-in theme.`},primary:{type:`string`,description:`Brand colour as #rrggbb.`,pattern:`^#[0-9a-fA-F]{6}$`},colorScheme:{enum:[`light`,`dark`,`system`],description:`Light, dark or follow the device.`},fontFamily:{type:[`string`,`null`],minLength:1,description:`Font key. Null restores the preset font.`},borderRadius:{enum:[`none`,`sm`,`md`,`lg`,`xl`,`full`],description:`Corner roundness.`},density:{enum:[`comfortable`,`touch`],description:`Control size: comfortable, or larger touch targets.`},contrast:{enum:[`auto`,`standard`,`more`],description:`Contrast: auto follows the device, or force standard or more.`}})},{name:`reset_theme`,description:`Go back to the default look.`,inputSchema:H({})},{name:`set_name`,description:`Name and describe the app. null clears a part.`,inputSchema:H({name:{type:[`string`,`null`],minLength:1,maxLength:60},description:{type:[`string`,`null`],minLength:1,maxLength:400}})},{name:`rename_section`,description:`Rename a menu section.`,inputSchema:H({id:a(`the section`),label:un(`The new name.`,{maxLength:60})},[`id`,`label`])},{name:`rename_item`,description:`Rename a menu entry. A null label restores its own name.`,inputSchema:H({id:a(`the entry`),label:{type:[`string`,`null`],minLength:1,maxLength:60}},[`id`,`label`])},{name:`hide`,description:`Hide a menu section or entry. Nothing is deleted.`,inputSchema:H({id:a(`the section or entry`)},[`id`])},{name:`show`,description:`Show a hidden menu section or entry again.`,inputSchema:H({id:a(`the section or entry`)},[`id`])},{name:`validate`,description:`Check the current cookbook against the catalog and report typed diagnostics. Changes nothing.`,inputSchema:H({})},{name:`export_cookbook`,description:`The cookbook as a <name>.cookbook.json file (text in the result). Changes nothing.`,inputSchema:H({name:un(`A name for the file.`,{maxLength:60})})},{name:`undo`,description:`Undo an earlier change by the undoId its receipt carried. Refused with a conflict when the plan changed since, unless force is true.`,inputSchema:H({undoId:un(`The undoId from a receipt.`),force:{type:`boolean`,description:`Undo even after later edits.`}},[`undoId`])}]}function fn(e){return{name:`run_batch`,description:`Run several commands as one atomic batch: all apply or none does. A failure names the command and leaves the plan unchanged.`,inputSchema:{type:`object`,properties:{id:{type:`string`,minLength:1,maxLength:200},expectedRevision:{type:`integer`,minimum:0},commands:{type:`array`,minItems:1,maxItems:50,items:{oneOf:dn(e).map(e=>({type:`object`,properties:{name:{const:e.name},input:e.inputSchema},required:[`name`],additionalProperties:!1}))}}},required:[`commands`],additionalProperties:!1}}}var pn=e=>e===null?`null`:Array.isArray(e)?`array`:Number.isInteger(e)?`integer`:typeof e;function mn(e,t){let n=pn(t);return n===e||e===`number`&&n===`integer`}function hn(e,t,n=`input`){let r=e=>({path:n,message:`${n} ${e}`}),i=e.type;if(i){let e=Array.isArray(i)?i:[i];if(!e.some(e=>mn(e,t)))return r(`must be ${e.join(` or `)}`)}let a=e.enum;if(a&&!a.includes(t))return r(a.length>12?`is not a known value`:`must be one of ${a.map(e=>JSON.stringify(e)).join(`, `)}`);if(typeof t==`string`){let{minLength:n,maxLength:i,pattern:a}=e;if(n!==void 0&&t.length<n)return r(`must not be empty`);if(i!==void 0&&t.length>i)return r(`must be at most ${i} characters`);if(a&&!new RegExp(a).test(t))return r(`has the wrong format`)}if(typeof t==`number`){let{minimum:n,maximum:i}=e;if(!Number.isFinite(t))return r(`must be a finite number`);if(n!==void 0&&t<n)return r(`must be at least ${n}`);if(i!==void 0&&t>i)return r(`must be at most ${i}`)}if(Array.isArray(t)){let{minItems:i,maxItems:a,items:o}=e;if(i!==void 0&&t.length<i)return r(`needs at least ${i} item${i===1?``:`s`}`);if(a!==void 0&&t.length>a)return r(`takes at most ${a} items`);if(o)for(let[e,r]of t.entries()){let t=hn(o,r,`${n}[${e}]`);if(t)return t}}if(pn(t)===`object`){let r=t,{properties:i,required:a,additionalProperties:o}=e;for(let e of a??[])if(r[e]===void 0)return{path:`${n}.${e}`,message:`${n}.${e} is required`};for(let[e,t]of Object.entries(r)){let r=i?.[e];if(!r){if(o===!1)return{path:`${n}.${e}`,message:`${n}.${e} is not an option of this command`};continue}if(t===void 0)continue;let a=hn(r,t,`${n}.${e}`);if(a)return a}}return null}function gn(e){return Object.fromEntries(dn(e).map(e=>[e.name,e.inputSchema]))}var U=(e,t,n={})=>({code:e,message:t,...n}),_n=e=>Array.isArray(e)?e.map(_n):e&&typeof e==`object`?Object.fromEntries(Object.keys(e).sort().map(t=>[t,_n(e[t])])):e,vn=e=>{try{return JSON.stringify(_n(e))??`undefined`}catch{return`unserializable`}};function yn(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return{ok:!1,error:U(`unknown_command`,`A command is an object: { name, input }.`)};let r=e,{name:i,input:a={}}=r;if(typeof i!=`string`||!Object.hasOwn(t,i))return{ok:!1,error:U(`unknown_command`,`Unknown command ${JSON.stringify(i)}.`)};for(let e of Object.keys(r))if(e!==`name`&&e!==`input`&&!n.includes(e))return{ok:!1,error:U(`invalid_input`,`${e} is not part of a command.`,{path:e})};let o=hn(t[i],a);return o?{ok:!1,error:U(`invalid_input`,o.message,{path:o.path})}:{ok:!0,name:i,input:a}}var bn=e=>e===void 0||typeof e==`string`&&e.length>0&&e.length<=200?null:U(`invalid_input`,`id must be a non-empty string of at most 200 characters.`,{path:`id`}),xn=e=>e===void 0||Number.isInteger(e)&&e>=0?null:U(`invalid_input`,`expectedRevision must be a whole number.`,{path:`expectedRevision`});function Sn(e){let{catalog:t}=e,n=gn(t),r=dn(t),i=fn(t),a=e.maxJournal??500,o=e.maxUndo??20,s,c=0,l=new Map;if(e.state){let n=e.state,r=bt(n.cookbook);if(!r.ok)throw Error(`Invalid saved cookbook: ${r.errors.join(`; `)}`);if(!Number.isInteger(n.revision)||n.revision<0)throw Error(`Invalid saved revision.`);s={doc:$t(t,r.cookbook),applied:n.applied??null},c=n.revision;for(let e of n.journal??[])l.set(e.id,I(e))}else if(e.cookbook!==void 0){let n=bt(e.cookbook);if(!n.ok)throw Error(`Invalid cookbook: ${n.errors.join(`; `)}`);s={doc:$t(t,n.cookbook),applied:null}}else s={doc:$t(t,St()),applied:null};let u=new Map,d=[],f=0,p=new Map;function m(e,n){let{doc:r}=e,i=new Map(t.recipes.map(e=>[e.id,e])),a=Ht(t,r),o=new Set(t.models.filter(e=>e.exposed!==!1).map(e=>e.id));return{version:1,revision:n,app:{name:r.name??en(t,e.applied)??`my-app`,description:r.description??null,cookbook:e.applied},recipes:r.recipes.flatMap(e=>{let t=i.get(e);return t?[{id:e,label:t.label}]:[]}),features:r.features.filter(e=>o.has(e)),unavailable:[...r.recipes.filter(e=>!i.has(e)),...r.features.filter(e=>!o.has(e))],settings:{currency:a.currency,taxRate:Number((a.taxRate*100).toFixed(4)),paymentTerms:a.paymentTerms,pricesIncludeTax:a.pricesIncludeTax,taxRounding:a.taxRounding},theme:{text:qt(r.theme),preset:r.theme?.preset??null,primary:r.theme?.custom?.primary??null,colorScheme:r.theme?.colorScheme??`system`,borderRadius:r.theme?.borderRadius??null,density:r.theme?.density??null,contrast:r.theme?.contrast??null},sections:Ze(t,r).map(e=>({id:e.id,label:e.label,hidden:e.hidden,items:e.items.map(e=>({id:e.id,label:e.label,hidden:e.hidden}))})),policies:r.policies.length,undo:[...d]}}let h=()=>m(s,c);function g(){for(let[e,t]of p)t!==c&&(p.set(e,c),e(h()))}function _(e,t,n){if(e!==void 0)for(l.set(e,{id:e,fingerprint:t,result:I(n)});l.size>a;){let e=l.keys().next().value;if(e===void 0)break;l.delete(e)}}function v(e,t){if(e===void 0)return null;let n=l.get(e);return n?n.fingerprint===t?{...I(n.result),replayed:!0}:{ok:!1,id:e,error:U(`id_reuse`,`The id "${e}" was already used for a different command.`,{path:`id`})}:null}function y(t,n){let r=`${e.undoPrefix??`undo`}-${++f}`;u.set(r,{before:I(t),after:I(n)}),d=[...d,r].slice(-o);for(let e of[...u.keys()])d.includes(e)||u.delete(e);return r}let b=(e,t)=>e.applied!==t.applied||!xt(e.doc,t.doc);function x(e,t,n,r,i,a,o){return{ok:!0,...e===void 0?{}:{id:e},snapshot:a,receipt:{name:t,...e===void 0?{}:{id:e},summary:i===r?``:n.summary,changed:i!==r,revisionBefore:r,revisionAfter:i,...o?{undoId:o}:{},...n.changes?{changes:n.changes}:{},...n.warnings?{warnings:n.warnings}:{}},...n.data===void 0?{}:{data:n.data}}}function S(e,t){let n=u.get(t.undoId);if(!n)return{ok:!1,...e===void 0?{}:{id:e},error:U(`not_found`,`Nothing to undo for "${t.undoId}".`,{path:`input.undoId`})};if(!t.force&&b(s,n.after))return{ok:!1,...e===void 0?{}:{id:e},error:U(`conflict`,`The plan changed since; send force: true to undo anyway.`,{details:{currentRevision:c}})};let r=c,i=I(n.before),a=b(s,i);s=i,a&&(c+=1),u.delete(t.undoId),d=d.filter(e=>e!==t.undoId);let o=x(e,`undo`,{ok:!0,state:s,summary:`Undone.`},r,c,h());return g(),o}function C(e,r={}){try{let i=e&&typeof e==`object`&&!Array.isArray(e)?e:void 0,a=i?.id,o=bn(a);if(o)return{ok:!1,error:o};let l=i?.expectedRevision??r.expectedRevision,u=xn(l);if(u)return{ok:!1,...a===void 0?{}:{id:a},error:u};let d=vn({name:i?.name,input:i?.input??{},expectedRevision:l}),f=v(a,d);if(f)return f;let p=e=>(_(a,d,e),e),m=e=>({ok:!1,...a===void 0?{}:{id:a},error:e}),C=yn(e,n,[`id`,`expectedRevision`]);if(!C.ok)return p(m(C.error));if(l!==void 0&&l!==c)return p(m(U(`conflict`,`The plan is at revision ${c}, not ${l}. Read the snapshot and try again.`,{details:{expectedRevision:l,currentRevision:c}})));if(C.name===`undo`)return p(S(a,C.input));let w=s,T=cn(t,w,C.name,C.input);if(!T.ok)return p(m(T.error));let E=c,D=b(w,T.state),O;D&&(s=T.state,c+=1,O=y(w,T.state));let ee=p(x(a,C.name,T,E,c,h(),O));return g(),ee}catch(e){return{ok:!1,error:U(`failed`,e instanceof Error?e.message:String(e))}}}function w(e){let r=(e,t)=>({ok:!1,...t===void 0?{}:{id:t},error:e,snapshot:h()});try{if(!e||typeof e!=`object`||Array.isArray(e))return r(U(`invalid_input`,`A batch is an object: { commands }.`));let i=e,a=i.id,o=bn(a);if(o)return r(o);let l=xn(i.expectedRevision);if(l)return r(l,a);let u=vn({commands:i.commands,expectedRevision:i.expectedRevision}),d=v(a,u);if(d)return`results`in d||`snapshot`in d?d:r(d.error,a);let f=e=>(_(a,u,e),e),p=i.commands;if(!Array.isArray(p)||p.length===0||p.length>50)return f(r(U(`invalid_input`,`commands must be a list of 1 to 50 commands.`,{path:`commands`}),a));let S=i.expectedRevision;if(S!==void 0&&S!==c)return f(r(U(`conflict`,`The plan is at revision ${c}, not ${S}. Read the snapshot and try again.`,{details:{expectedRevision:S,currentRevision:c}}),a));let C=(e,t,n)=>f(r(U(`batch_failed`,`Command ${e+1} (${String(t)}) failed: ${n.message}`,{path:`commands[${e}]`,details:{index:e,cause:n}}),a)),w=s,T=c,E=w,D=T,O=[];for(let[e,r]of p.entries()){let i=yn(r,n,[]);if(!i.ok)return C(e,r?.name,i.error);if(i.name===`undo`)return C(e,`undo`,U(`invalid_input`,`undo cannot run inside a batch.`));let a=cn(t,E,i.name,i.input);if(!a.ok)return C(e,i.name,a.error);let o=D;b(E,a.state)&&(D+=1),E=a.state,O.push(x(void 0,i.name,a,o,D,m(E,D)))}let ee=D!==T,te;if(ee){s=E,c=D,te=y(w,E);for(let e of O)e.receipt.changed&&delete e.receipt.undoId}let ne=f({ok:!0,...a===void 0?{}:{id:a},snapshot:h(),receipt:{...a===void 0?{}:{id:a},count:O.length,changed:ee,revisionBefore:T,revisionAfter:D,...te?{undoId:te}:{}},results:O});return g(),ne}catch(e){return r(U(`failed`,e instanceof Error?e.message:String(e)))}}return{run:C,batch:w,snapshot:h,cookbook:()=>I(s.doc),state:()=>({version:1,revision:c,applied:s.applied,cookbook:I(s.doc),journal:[...l.values()].map(e=>I(e))}),subscribe(e){return p.set(e,c),e(h()),()=>{p.delete(e)}},tools:r,batchTool:i}}var Cn=new Set(`AED AFN ALL AMD ANG AOA ARS AUD AWG AZN BAM BBD BDT BGN BHD BIF BMD BND BOB BRL BSD BTN BWP BYN BZD CAD CDF CHF CLP CNY COP CRC CUP CVE CZK DJF DKK DOP DZD EGP ERN ETB EUR FJD FKP GBP GEL GHS GIP GMD GNF GTQ GYD HKD HNL HTG HUF IDR ILS INR IQD IRR ISK JMD JOD JPY KES KGS KHR KMF KPW KRW KWD KYD KZT LAK LBP LKR LRD LSL LYD MAD MDL MGA MKD MMK MNT MOP MRU MUR MVR MWK MXN MYR MZN NAD NGN NIO NOK NPR NZD OMR PAB PEN PGK PHP PKR PLN PYG QAR RON RSD RUB RWF SAR SBD SCR SDG SEK SGD SHP SLE SOS SRD SSP STN SYP SZL THB TJS TMT TND TOP TRY TTD TWD TZS UAH UGX USD UYU UZS VES VND VUV WST XAF XCD XOF XPF YER ZAR ZMW ZWG`.split(` `));function wn(){let e=u.packages.flatMap(e=>e.models.map(t=>({id:t.id,name:t.name,packageId:e.id,...t.description?{description:t.description}:{},exposed:t.exposed,fields:t.fields.map(e=>({name:e.name,...e.system?{system:!0}:{},...e.default===void 0?{}:{default:e.default}}))})));return{recipes:D,models:e,cookbooks:k.map(e=>({id:e.id,name:e.name,document:e.document})),themePresets:x,currencies:[...Cn],settingTargets:te}}var Tn;function En(){return Tn??=wn(),Tn}var Dn=[`cookbooks`,`recipes`,`features`,`layout`,`theme`,`settings`,`export`],On={name:`focus`,description:`Move the planner's view to a tab and/or a menu section. Navigation only; it changes nothing in the plan.`,inputSchema:{type:`object`,properties:{tab:{enum:[...Dn],description:`The tab to open.`},section:{type:`string`,minLength:1,maxLength:200,description:`The id of a menu section, as the plan snapshot's "sections" lists it.`}},additionalProperties:!1}};function kn(e){return[...dn(e),On]}function An(e,t){return kn({...En(),recipes:e.map(e=>({id:e,label:e,models:[],nav:[],requires:[]})),cookbooks:t.map(e=>({id:e,name:e,document:{}}))})}var jn=An(D.map(e=>e.id),k.map(e=>e.id));Object.fromEntries(jn.map(e=>[e.name,e.inputSchema])),jn.map(e=>e.name);function Mn(e,t,n=`input`){return hn(e,t,n)?.message??null}function Nn(e){let t=e;return{get:()=>t,set:e=>{t=e}}}var W=(e,t,n={})=>({code:e,message:t,...n}),G=(e,t)=>({ok:!1,...t===void 0?{}:{id:t},error:e}),K=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Pn=new Set([`apply_cookbook`,`import_cookbook`]),Fn=e=>e instanceof Error?e.message:String(e);function In(e,t){if(!K(e))return JSON.stringify([t,e??null]);let{overviews:n,...r}=e;return JSON.stringify([t,r])}function Ln(e){let{catalog:t,port:n,options:r={},env:i={}}=e,a=i.section??Nn(null),o=i.tab??Nn(null),s=kn(t),c=e=>s.find(t=>t.name===e)?.inputSchema,l=c(`focus`),u=c(`undo`),d,f=``,p=null,m=new Map,h=new Map,g=0,_=new Map,v=()=>n?.applied?.()??null,y=()=>r.navigation?.getTab()??o.get();function b(){if(!n?.read){d=Sn(e.cookbook===void 0?{catalog:t}:{catalog:t,state:{version:1,revision:0,applied:null,cookbook:e.cookbook,journal:[]}});return}let r=n.read();f=In(r,v());try{d=Sn({catalog:t,state:{version:1,revision:0,applied:v(),cookbook:r,journal:[]}})}catch(e){d=Sn({catalog:t}),p=Fn(e)}}b();function x(e,n){let r=d.state();try{d=Sn({catalog:t,state:{version:1,revision:r.revision+1,applied:v(),cookbook:e,journal:r.journal}}),p=null}catch(e){p=Fn(e)}m=new Map,h=new Map,f=n}function S(){if(n?.read)try{let e=n.read(),t=In(e,v());if(t===f)return;x(e,t)}catch(e){p=Fn(e)}}let C=()=>W(`failed`,`The app's document is not one the planner can read (${p}). Fix it or reset the cookbook, then try again.`),w=e=>G(C(),e);function T(e){if(!e)return;let t=m.get(e);return t||(t=`undo-${++g}`,m.set(e,t),h.set(t,e)),t}function E(e){let t=new Set(e);for(let[e,n]of m)t.has(e)||(m.delete(e),h.delete(n))}let D=e=>({...e,undo:e.undo.map(e=>T(e)),focus:{tab:y(),section:a.get()}});function O(){let e=d.snapshot();return E(e.undo),D(e)}function ee(e){if(!n?.read)return e;try{let t=n.read(),r=K(t)?t.overviews:void 0,{overviews:i,...a}=e;return Tt(K(r)&&Object.keys(r).length?{...a,overviews:r}:a)}catch{return e}}function te(e){if(!e.ok)return e;let{receipt:t}=e,n=e.replayed?void 0:T(t.undoId),{undoId:r,...i}=t,a=e.data;if(t.name===`export_cookbook`&&K(a)&&!e.replayed){let e=ee(a.cookbook);a={...a,cookbook:e,text:`${JSON.stringify(e,null,2)}\n`}}return{...e,...a===void 0?{}:{data:a},snapshot:O(),receipt:{...i,...n?{undoId:n}:{}}}}function ne(e,t){if(!n?.write)return;let i=d.snapshot().app.cookbook,a=e.includes(`apply_cookbook`)||i!==null&&i!==t;n.write(d.cookbook(),{commands:e,replaced:e.some(e=>Pn.has(e)),applied:i,libraryApplied:a}),n.read&&(f=In(n.read(),v())),a&&r.onReplaced?.()}function k(){if(!_.size)return;S();let e=O(),t=JSON.stringify(e);for(let[n,r]of _)r!==t&&(_.set(n,t),n(e))}function re(e,t){for(let t of Object.keys(e))if(![`name`,`input`,`id`,`expectedRevision`].includes(t))return W(`invalid_input`,`${t} is not part of a command.`,{path:t});let{id:n}=e;if(n!==void 0&&!(typeof n==`string`&&n.length>0&&n.length<=200))return W(`invalid_input`,`id must be a non-empty string of at most 200 characters.`,{path:`id`});let r=e.expectedRevision??t.expectedRevision;return r!==void 0&&!(Number.isInteger(r)&&r>=0)?W(`invalid_input`,`expectedRevision must be a whole number.`,{path:`expectedRevision`}):null}function ie(e,t){let n=re(e,t),i=typeof e.id==`string`?e.id:void 0;if(n)return G(n,i);let s=e.expectedRevision??t.expectedRevision,c=e.input??{},u=Mn(l,c);if(u)return G(W(`invalid_input`,u,{path:`input`}),i);let f=d.snapshot().revision;if(s!==void 0&&s!==f)return G(W(`conflict`,`The plan is at revision ${f}, not ${s}. Read the snapshot and try again.`,{details:{expectedRevision:s,currentRevision:f}}),i);if(c.section!==void 0&&!O().sections.some(e=>e.id===c.section))return G(W(`not_found`,`No menu section "${c.section}".`,{path:`input.section`}),i);let p=!1;c.tab&&Dn.includes(c.tab)&&(p||=y()!==c.tab,o.set(c.tab),r.navigation?.setTab(c.tab)),c.section!==void 0&&(p||=a.get()!==c.section,a.set(c.section),r.navigation?.setSection?.(c.section));let m={ok:!0,...i===void 0?{}:{id:i},snapshot:O(),receipt:{name:`focus`,...i===void 0?{}:{id:i},summary:``,changed:p,revisionBefore:f,revisionAfter:f}};return k(),m}function ae(e){let t=e.input;if(!n?.prepareImport||!K(t))return{raw:e};let r=n.prepareImport(t.document);return r.ok?{raw:{...e,input:{...t,document:r.cookbook}},dropped:r.dropped}:G(W(`invalid_input`,r.error,{path:`input.document`}),e.id)}function oe(e){if(n?.read&&e.some(e=>typeof e==`string`&&Pn.has(e)))try{let e=n.read();if(Ct(d.cookbook())&&!Ct(e)){let n=d.state();d=Sn({catalog:t,state:{version:1,revision:n.revision,applied:v(),cookbook:e,journal:n.journal}}),m=new Map,h=new Map,f=In(e,v())}}catch(e){p=Fn(e)}}function se(e,t={}){try{if(S(),p)return w(K(e)&&typeof e.id==`string`?e.id:void 0);if(!K(e))return te(d.run(e,t));if(e.name===`focus`)return ie(e,t);if(oe([e.name]),p)return w(typeof e.id==`string`?e.id:void 0);let n=e,r;if(e.name===`import_cookbook`){let t=ae(e);if(`ok`in t)return t;n=t.raw,r=t.dropped}let i=d.snapshot().app.cookbook,a=ce(n),o=a?le(n,t,a):te(d.run(n,t));if(!o.ok)return o;!o.replayed&&o.receipt.changed&&ne([String(n.name)],i);let s=o;return r?.length&&(s={...o,receipt:{...o.receipt,warnings:[...o.receipt.warnings??[],...r.map(e=>`Not imported: ${e}`)]}}),k(),s.ok?{...s,snapshot:O()}:s}catch(e){return G(W(`failed`,Fn(e)))}}function ce(e){let n=e.input;if(e.name!==`apply_cookbook`||!K(n))return;let r=t.cookbooks?.find(e=>e.id===n.id);if(!r)return;let i=d.cookbook().theme;if(!i)return;let a=r.document.theme;if(a)return a.colorScheme||!i.colorScheme?void 0:{colorScheme:i.colorScheme};let o={};return i.preset&&(o.preset=i.preset),i.custom?.primary&&(o.primary=i.custom.primary),i.colorScheme&&(o.colorScheme=i.colorScheme),i.borderRadius&&(o.borderRadius=i.borderRadius),i.density&&(o.density=i.density),i.contrast&&(o.contrast=i.contrast),Object.keys(o).length?o:void 0}function le(e,t,n){let r=d.batch({...e.id===void 0?{}:{id:e.id},expectedRevision:e.expectedRevision??t.expectedRevision,commands:[e,{name:`set_theme`,input:n}].map(({id:e,expectedRevision:t,...n})=>n)});if(!r.ok){let t=r.error.details?.cause;return G(r.error.code===`batch_failed`&&t?t:r.error,e.id)}let i=r.results[0],a=r.replayed?void 0:T(r.receipt.undoId);return{...i,...r.id===void 0?{}:{id:r.id},...r.replayed?{replayed:!0}:{},snapshot:O(),receipt:{...i.receipt,...r.id===void 0?{}:{id:r.id},revisionBefore:r.receipt.revisionBefore,revisionAfter:r.receipt.revisionAfter,changed:r.receipt.changed,...a?{undoId:a}:{}}}}function ue(e){try{if(S(),p)return{ok:!1,error:C(),snapshot:O()};let t=K(e)&&Array.isArray(e.commands)?e.commands:[];if(oe(t.map(e=>K(e)?e.name:void 0)),p)return{ok:!1,error:C(),snapshot:O()};let n=d.snapshot().app.cookbook,r=d.batch(e);if(!r.ok)return{...r,snapshot:O()};!r.replayed&&r.receipt.changed&&ne(t.map(e=>String(e?.name)),n);let i=r.replayed?void 0:T(r.receipt.undoId),{undoId:a,...o}=r.receipt,s=O(),c={...r,snapshot:s,receipt:{...o,...i?{undoId:i}:{}},results:r.results.map(e=>({...e,snapshot:r.replayed?s:D(e.snapshot)}))};return k(),c}catch(e){return{ok:!1,error:W(`failed`,Fn(e)),snapshot:O()}}}function A(e){if(!K(e)||e.name!==`undo`||!K(e.input))return e;let t=e.input.undoId;return typeof t==`string`?{...e,input:{...e.input,undoId:h.get(t)??``}}:e}function de(e,t){if(e.ok||e.error.code!==`not_found`)return e;let n=h.get(t);return n?{...e,error:{...e.error,message:e.error.message.replace(`"${n}"`,`"${t}"`)}}:e}let fe=(e,t)=>{if(K(e)&&e.name===`undo`&&K(e.input)){let n=e.input.undoId;if(typeof n==`string`&&Mn(u,e.input)===null)return S(),O(),h.has(n)?de(se(A(e),t),n):G(W(`not_found`,`Nothing to undo for "${n}".`,{path:`input.undoId`}),e.id)}return se(A(e),t)};return{run:fe,batch:ue,snapshot(){return S(),O()},cookbook(){return S(),ee(d.cookbook())},undo(){S();let e=O().undo.at(-1);return e?fe({name:`undo`,input:{undoId:e}}):G(W(`not_found`,`Nothing to undo.`))},state:()=>d.state(),get tools(){return s},get batchTool(){return d.batchTool},observe(){return S(),JSON.stringify(O())},deliver:k,subscribe(e){i.watch?.start(),S();let t=O();return _.set(e,JSON.stringify(t)),e(t),()=>{_.delete(e),_.size||i.watch?.stop()}}}}function Rn(e){return e.recipes.length===0&&e.features.length===0&&e.policies.length===0&&Object.keys(e.exposure??{}).length===0&&e.theme===void 0&&d(e.layout)}function zn(e){if(!e.theme?.colorScheme)return e;let{colorScheme:t,...n}=e.theme;return{...e,theme:Object.keys(n).length?n:void 0}}function Bn(e){return JSON.stringify(zn(e))}function Vn(e,t){let n=zn(e);return Rn(n)?!1:t===null||JSON.stringify(n)!==t}function Hn(e,t,n){return t(n?O(structuredClone(e.document),n):e.document)}var Un=`smrt-planner:cookbook`,Wn=`smrt-planner:cookbook-applied`,Gn=new class{#e=n(null);get active(){return e(this.#e)}set active(e){s(this.#e,e,!0)}#t=n(null);get appliedWork(){return e(this.#t)}set appliedWork(e){s(this.#t,e,!0)}load(e=v()){try{this.active=e?.getItem(`smrt-planner:cookbook`)??null,this.appliedWork=e?.getItem(`smrt-planner:cookbook-applied`)??null}catch{this.active=null,this.appliedWork=null}l(this.active)}select(e,t=null,n=v()){this.active=e,this.appliedWork=t;try{n?.setItem(Un,e),t===null?n?.removeItem(Wn):n?.setItem(Wn,t)}catch{}}};function Kn(t){let r=n(i(t));return{get:()=>e(r),set:e=>{s(r,e,!0)}}}function qn(e){return{read:()=>e.snapshot(),applied:()=>Gn.active,prepareImport:e=>w(e),write(t,{replaced:n,applied:r,libraryApplied:i}){let a=n?t:{...t,overviews:e.snapshot().overviews};n?e.replace(a):e.apply(a),i&&r&&(Gn.select(r,Bn(e.snapshot())),l(r))}}}function Jn(e=C,t={}){let n,i=Ln({catalog:En(),port:qn(e),options:t,env:{section:Kn(null),tab:Kn(null),watch:{start(){n||=o(()=>{r(()=>{i.observe(),a(i.deliver)})})},stop(){n?.(),n=void 0}}}});return i}var Yn=()=>({$schema:y,version:1,recipes:[],features:[],policies:[]});function Xn(e){let{store:t,settings:n,theme:r}=e;return{read(){let e={...Yn(),recipes:[...t.ids].sort()};n&&(e=O(e,n.read()));let i=r?.read();return i?{...e,theme:i}:e},write(e){let i=new Set(e.recipes),a=new Set(t.ids),o=[...a].filter(e=>!i.has(e));o.length&&t.remove(...o);let s=[...i].filter(e=>!a.has(e));s.length&&t.add(...s),n&&n.write(ee(e)),r?.write(e.theme)}}}function Zn(e,t={}){return Ln({catalog:En(),port:Xn(e),options:t})}var Qn=[`cookbooks`,`recipes`,`features`,`layout`,`theme`,`settings`,`export`];function $n(e,t=`cookbooks`){let n=new URLSearchParams(e).get(`tab`);return Qn.find(e=>e===n)??t}var er=new class{#e=n(`cookbooks`);get active(){return e(this.#e)}set active(e){s(this.#e,e,!0)}fromSearch(e,t=`cookbooks`){this.active=$n(e,t)}leaveExport(e=`cookbooks`){this.active===`export`&&(this.active=e)}},tr={},nr=Jn(C,{navigation:{getTab:()=>er.active,setTab:e=>{er.active=e},setSection:e=>tr.openSection?.(e)},onReplaced:()=>tr.onReplaced?.()}),rr=`Qwen3-1.7B-q4f16_1-MLC`,ir=[{id:rr,label:`Qwen3 1.7B (recommended)`,downloadMB:1100,vramMB:2037},{id:`Llama-3.2-1B-Instruct-q4f16_1-MLC`,label:`Llama 3.2 1B (smallest)`,downloadMB:700,vramMB:879},{id:`Qwen3-4B-q4f16_1-MLC`,label:`Qwen3 4B (smarter, larger)`,downloadMB:2300,vramMB:3432}];function ar(e){return ir.find(t=>t.id===e)}function or(e){return e>=1e3?`about ${(e/1e3).toFixed(1)} GB`:`about ${e} MB`}function sr(e){return e.label.replace(/\s*\(.*\)\s*$/,``)}var cr=`Qwen3-4B-q4f16_1-MLC`;function lr(e,t){return t>=e.vramMB*1e6*1.2}async function ur(e=typeof navigator>`u`?void 0:navigator){try{return(await e?.gpu?.requestAdapter())?.limits?.maxBufferSize??0}catch{return 0}}function dr(e){return typeof e==`string`?e:e.filter(e=>e.type===`text`).map(e=>e.text).join(`
23
- `)}var q=class extends Error{code;provider;model;retryable;constructor(e,t,n,r,i=!1){super(e),this.code=t,this.provider=n,this.model=r,this.retryable=i,this.name=`AIError`}},fr=class extends q{constructor(e,t){super(`Model not found: ${e}`,`MODEL_NOT_FOUND`,t,e,!1),this.name=`ModelNotFoundError`}},pr=class extends q{constructor(e,t){super(`Input exceeds maximum context length`,`CONTEXT_LENGTH_EXCEEDED`,e,t,!1),this.name=`ContextLengthError`}},mr=class extends q{constructor(e=`webllm`,t){super(t??`WebGPU is not available in this environment (navigator.gpu is missing); on-device inference cannot run.`,`WEBGPU_UNAVAILABLE`,e,void 0,!1),this.name=`WebGPUUnavailableError`}},hr=class extends q{constructor(e){super("The webllm provider needs the optional peer dependency @mlc-ai/web-llm. Install it with `pnpm add @mlc-ai/web-llm` (or the npm/yarn equivalent).",`WEBLLM_PEER_MISSING`,`webllm`,void 0,!1),this.name=`WebLLMPeerMissingError`,e!==void 0&&(this.cause=e)}},gr=12e4,_r=Object.freeze({maxOutputTokens:131072,defaultOutputTokens:4096,maxReasoningTokens:1024,maxImagesPerRequest:1,onExceeded:`error`});function J(e,t,n){if(e===void 0)return t;if(!Number.isFinite(e)||e<=0)throw new q(`${n} must be a positive finite number`,`AI_LIMIT_INVALID`);return Math.trunc(e)}function vr(e){let t=e.generationLimits||{},n={maxOutputTokens:J(t.maxOutputTokens,_r.maxOutputTokens,`generationLimits.maxOutputTokens`),defaultOutputTokens:Math.min(J(t.defaultOutputTokens,_r.defaultOutputTokens,`generationLimits.defaultOutputTokens`),J(t.maxOutputTokens,_r.maxOutputTokens,`generationLimits.maxOutputTokens`)),maxReasoningTokens:J(t.maxReasoningTokens,_r.maxReasoningTokens,`generationLimits.maxReasoningTokens`),maxImagesPerRequest:J(t.maxImagesPerRequest,_r.maxImagesPerRequest,`generationLimits.maxImagesPerRequest`),onExceeded:t.onExceeded||_r.onExceeded};if(![`error`,`clamp`].includes(n.onExceeded))throw new q(`generationLimits.onExceeded must be "error" or "clamp"`,`AI_LIMIT_INVALID`);return{...e,timeout:J(e.timeout,gr,`timeout`),maxRetries:(()=>{if(e.maxRetries===void 0)return 0;if(!Number.isFinite(e.maxRetries)||e.maxRetries<0)throw new q(`maxRetries must be a non-negative finite number`,`AI_LIMIT_INVALID`);return Math.trunc(e.maxRetries)})(),generationLimits:n}}function yr(e){switch(e){case!1:case`none`:return 0;case`minimal`:return 1024;case`low`:return 2048;case`medium`:return 4096;case`high`:return 8192;default:return}}function br(e,t,n,r,i,a){if(!Number.isFinite(e)||e<0)throw new q(`${r} must be a non-negative finite number`,`AI_LIMIT_INVALID`,i,a);let o=Math.trunc(e);if(o<=t)return o;if(n===`clamp`)return t;throw new q(`${r} ${o} exceeds configured ceiling ${t}`,`AI_LIMIT_EXCEEDED`,i,a)}function xr(e,t,n,r){let i=vr(e).generationLimits,a=t.maxTokens??i.defaultOutputTokens??i.maxOutputTokens,o=t.thinkingLevel??e.thinkingLevel,s=t.reasoning!==void 0||o!==void 0||t.includeThoughts===!0?t.reasoning?.maxTokens??yr(t.reasoning?.effort??o)??i.maxReasoningTokens:0;return{...t,maxTokens:br(a,i.maxOutputTokens,i.onExceeded,`maxTokens`,n,r),reasoning:{...t.reasoning,maxTokens:br(s,i.maxReasoningTokens,i.onExceeded,`reasoning.maxTokens`,n,r),includeThoughts:t.reasoning?.includeThoughts??t.includeThoughts}}}function Sr(e,t={}){let n=vr(e),r=J(t.timeout,n.timeout,`timeout`),i=new AbortController,a=!1,o=()=>i.abort(t.signal?.reason);t.signal?.aborted?o():t.signal?.addEventListener(`abort`,o,{once:!0});let s=setTimeout(()=>{a=!0,i.abort(Error(`AI request timed out after ${r}ms`))},r);return{signal:i.signal,timeout:r,didTimeout:()=>a,cleanup:()=>{clearTimeout(s),t.signal?.removeEventListener(`abort`,o)}}}[...new Set([`getVideoGenerationJob`,`fetchVideoGenerationResult`,`cancelVideoGenerationJob`])];function Cr(e,t,n,r,i,a,o){if(!e.onUsage)return;let s=e.usageTags,c=s||o?{...s,...o}:void 0;try{e.onUsage({provider:t,model:r,operation:n,usage:i,duration:Date.now()-a,timestamp:new Date,tags:c})}catch{}}var Y=`webllm`,wr=4096,Tr={chat:!0,completion:!0,embeddings:!1,streaming:!0,functions:!0,vision:!1,fineTuning:!1,imageEmbeddings:!1,imageGeneration:!1,videoGeneration:!1,tts:!1,voiceCloning:!1,voiceDesign:!1,maxContextLength:wr,supportedOperations:[`chat`,`completion`,`streaming`,`functions`]},Er=new WeakMap,Dr=new Map;async function Or(){try{let e=await c(()=>import(`./DL8aLXmX.js`),[],import.meta.url),t=typeof e?.CreateMLCEngine==`function`?e:e?.default;if(typeof t?.CreateMLCEngine!=`function`)throw Error(`@mlc-ai/web-llm did not export CreateMLCEngine`);return t}catch(e){throw new hr(e)}}function kr(){return!!globalThis.navigator?.gpu}function X(e){throw new q(`${e} is not supported by the webllm provider.`,`NOT_SUPPORTED`,Y)}function Ar(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}var jr=class{options;explicitModel;factoryEngine;localEngines=new Map;constructor(e){this.explicitModel=e.defaultModel??e.model,this.options=vr({...e,defaultModel:this.explicitModel??`Llama-3.2-1B-Instruct-q4f16_1-MLC`})}async acquireEngine(e,t){let n=this.options.engine;if(n)return typeof n==`function`?(this.factoryEngine??=n().catch(e=>{throw this.factoryEngine=void 0,e}),Fr(this.factoryEngine,t)):n;if(!kr())throw new mr(Y);let r=this.options.appConfig?this.localEngines:Dr,i=r.get(e);if(!i){let t=new Set,n={listeners:t,promise:this.createEngine(e,t)};n.promise.catch(()=>{r.get(e)===n&&r.delete(e)}),r.set(e,n),i=n}let a=this.options.onLoadProgress;a&&i.listeners.add(a);try{return await Fr(i.promise,t)}finally{a&&i.listeners.delete(a)}}async createEngine(e,t){return(await Or()).CreateMLCEngine(e,{...this.options.appConfig?{appConfig:this.options.appConfig}:{},initProgressCallback:e=>{for(let n of t)try{n(e)}catch{}}})}mapMessages(e){return e.map(e=>{if(e.role===`user`&&Array.isArray(e.content))return{role:`user`,content:e.content.map(e=>e.type===`text`?{type:`text`,text:e.text}:{type:`image_url`,image_url:{url:e.image_url.url}}),...e.name?{name:e.name}:{}};let t=dr(e.content);return e.role===`tool`||e.role===`function`?{role:`tool`,content:t,tool_call_id:e.tool_call_id??e.name??``}:e.role===`assistant`?Ar({role:`assistant`,content:t||(e.tool_calls?.length?null:``),tool_calls:e.tool_calls?.map(e=>({id:e.id,type:e.type,function:{name:e.function.name,arguments:e.function.arguments}}))}):{role:e.role,content:t,...e.name?{name:e.name}:{}}})}mapResponseFormat(e){return e.responseSchema===void 0?e.responseFormat?.type===`json_object`?{type:`json_object`}:void 0:{type:`json_object`,schema:typeof e.responseSchema==`string`?e.responseSchema:JSON.stringify(e.responseSchema)}}buildRequest(e,t,n,r,i){let a=i&&t.tools?.length?t.tools.map(e=>({type:`function`,function:{name:e.function.name,description:e.function.description,parameters:e.function.parameters}})):void 0;return Ar({model:n,messages:this.mapMessages(e),max_tokens:t.maxTokens,temperature:t.temperature,top_p:t.topP,n:t.n,stop:t.stop,frequency_penalty:t.frequencyPenalty,presence_penalty:t.presencePenalty,seed:t.seed,tools:a,tool_choice:a?t.toolChoice:void 0,response_format:this.mapResponseFormat(t),stream:r,stream_options:r?{include_usage:!0}:void 0})}requestModel(e,t){return this.options.engine?t.model??this.explicitModel:e}mapUsage(e){let t=e;if(t)return{promptTokens:t.prompt_tokens??0,completionTokens:t.completion_tokens??0,totalTokens:t.total_tokens??0}}mapFinishReason(e){switch(e){case`length`:return`length`;case`tool_calls`:return`tool_calls`;default:return`stop`}}assertNotInterrupted(e,t){if(e===`abort`)throw new q(`Generation was interrupted before it finished`,`AI_INTERRUPTED`,Y,t,!0)}mapError(e,t){if(e instanceof q)return e;let n=e?.name??``,r=e instanceof Error?e.message:String(e);if(n===`WebGPUNotAvailableError`||n===`WebGPUNotFoundError`)return new mr(Y,r);if(n===`ContextWindowSizeExceededError`||n===`PrefillChunkSizeSmallerThanImageError`)return new pr(Y,t);if(n===`ModelNotFoundError`||n===`SpecifiedModelNotFoundError`||n===`UnsupportedModelIdError`||n===`ModelNotLoadedError`)return new fr(t??r,Y);let i=new q(r,n===`DeviceLostError`?`WEBGPU_DEVICE_LOST`:`API_ERROR`,Y,t);return i.cause=e,i}abortError(e,t,n){if(e?.didTimeout())return new q(`AI request timed out after ${e.timeout}ms`,`AI_TIMEOUT`,Y,n);if(t.signal?.aborted)return new q(`AI request aborted by caller`,`AI_ABORTED`,Y,n)}async lockEngine(e,t){let n=Er.get(e)??Promise.resolve(),r=()=>{},i=new Promise(e=>{r=e});Er.set(e,n.then(()=>i));try{await Fr(n,t)}catch(e){throw r(),e}return r}bindInterrupt(e,t){let n=()=>{try{Promise.resolve(e.interruptGenerate()).catch(()=>{})}catch{}};return t.aborted&&n(),t.addEventListener(`abort`,n,{once:!0}),()=>t.removeEventListener(`abort`,n)}async chat(e,t={}){let n=Date.now(),r,i,a,o,s,c=t.model||this.options.defaultModel||`Llama-3.2-1B-Instruct-q4f16_1-MLC`;try{t=xr(this.options,t,Y,c);let l=await this.acquireEngine(c,t.signal);r=Sr(this.options,t),a=await this.lockEngine(l,r.signal),i=this.bindInterrupt(l,r.signal),o=l.chat.completions.create(this.buildRequest(e,t,this.requestModel(c,t),!1,!0));let u=o,d=!1,f=()=>{d=!0};u.then(f,f),s=()=>d?void 0:u;let p=await Fr(o,r.signal);if(r.signal.aborted)throw this.abortError(r,t,c)??r.signal.reason;let m=p?.choices?.[0];if(this.assertNotInterrupted(m?.finish_reason,c),!m)throw new q(`No choices returned from webllm`,`NO_CHOICES`,Y);let h=this.mapUsage(p.usage);Cr(this.options,Y,`chat`,p.model||c,h,n,t.usageTags);let g=m.message?.tool_calls?.map(e=>({id:e.id,type:`function`,function:{name:e.function.name,arguments:e.function.arguments}}));return{content:m.message?.content||``,usage:h,model:p.model||c,finishReason:this.mapFinishReason(m.finish_reason),...g?.length?{toolCalls:g}:{}}}catch(e){throw this.abortError(r,t,c)??this.mapError(e,c)}finally{i?.(),Nr(a,s?.()),r?.cleanup()}}async complete(e,t={}){return this.chat([{role:`user`,content:e}],{model:t.model,maxTokens:t.maxTokens,temperature:t.temperature,topP:t.topP,n:t.n,stop:t.stop,stream:t.stream,onProgress:t.onProgress,signal:t.signal,timeout:t.timeout,reasoning:t.reasoning,usageTags:t.usageTags,continueOnLength:t.continueOnLength})}async message(e,t={}){let n=[...t.history||[],{role:t.role||`user`,content:e}];return(await this.chat(n,{model:t.model,maxTokens:t.maxTokens,temperature:t.temperature,topP:t.topP,stop:t.stop,stream:t.stream,frequencyPenalty:t.frequencyPenalty,presencePenalty:t.presencePenalty,responseFormat:t.responseFormat,responseSchema:t.responseSchema,seed:t.seed,tools:t.tools,toolChoice:t.toolChoice,onProgress:t.onProgress,signal:t.signal,timeout:t.timeout,reasoning:t.reasoning,usageTags:t.usageTags,continueOnLength:t.continueOnLength})).content}async*stream(e,t={}){let n=Date.now(),r,i,a,o,s,c=!1,l,u=t.model||this.options.defaultModel||`Llama-3.2-1B-Instruct-q4f16_1-MLC`;try{t=xr(this.options,t,Y,u),a=await this.acquireEngine(u,t.signal),r=Sr(this.options,t),o=await this.lockEngine(a,r.signal),i=this.bindInterrupt(a,r.signal);let d=a.chat.completions.create(this.buildRequest(e,t,this.requestModel(u,t),!0,!1)),f;try{f=await Fr(d,r.signal)}catch(e){throw l=d.then(e=>Pr(e[Symbol.asyncIterator](),a),()=>{}),e}s=f[Symbol.asyncIterator]();let p,m;for(;;){let e=await s.next();if(e.done){c=!0;break}let n=e.value,r=n.choices?.[0];p=r?.finish_reason??p,n.usage&&(m=this.mapUsage(n.usage));let i=r?.delta?.content;i&&(t.onProgress?.(i),yield i)}if(r.signal.aborted)throw this.abortError(r,t,u)??r.signal.reason;this.assertNotInterrupted(p,u),t.onFinishReason?.(this.mapFinishReason(p)),Cr(this.options,Y,`stream`,u,m,n,t.usageTags)}catch(e){throw this.abortError(r,t,u)??this.mapError(e,u)}finally{if(s&&!c&&a){try{Promise.resolve(a.interruptGenerate()).catch(()=>{})}catch{}await Mr(s)}i?.(),Nr(o,l),r?.cleanup()}}async countTokens(e){return Math.ceil(e.length/4)}async getModels(){let e=await Or(),t=this.options.appConfig?.model_list??e.prebuiltAppConfig.model_list,n=new Set(e.functionCallingModelIds??[]);return t.filter(e=>e.model_type!==1).map(e=>{let t=e.model_type===2,r=n.has(e.model_id);return{id:e.model_id,name:e.model_id,description:e.vram_required_MB?`Runs on-device via WebGPU (~${Math.round(e.vram_required_MB)} MB VRAM)`:`Runs on-device via WebGPU`,contextLength:e.overrides?.context_window_size??wr,capabilities:[`text`,`chat`,...r?[`functions`]:[],...t?[`vision`]:[]],supportsFunctions:r,supportsVision:t}})}async getCapabilities(){return{...Tr}}async embed(e,t={}){return X(`Embeddings`)}async embedImage(e,t={}){return X(`Image embeddings`)}async describeImage(e,t,n={}){return X(`Image description`)}async generateImage(e,t={}){return X(`Image generation`)}async submitVideoGenerationJob(e){return X(`Video generation`)}async getVideoGenerationJob(e){return X(`Video generation`)}async fetchVideoGenerationResult(e){return X(`Video generation`)}async cancelVideoGenerationJob(e){return X(`Video generation`)}async validateVideoGenerationAccess(){return X(`Video generation`)}async synthesizeSpeech(e,t){return X(`Text-to-speech`)}streamSpeech(e,t){let n=new q(`Text-to-speech streaming is not supported by the webllm provider.`,`NOT_SUPPORTED`,Y);return{[Symbol.asyncIterator]:()=>({next:()=>Promise.reject(n)})}}async cloneVoice(e){return X(`Voice cloning`)}async designVoice(e){return X(`Voice design`)}async getVoices(e){return X(`Voice listing`)}};async function Mr(e){try{for(;!(await e.next()).done;);}catch{}}function Nr(e,t){e&&(t?t.then(e,e):e())}async function Pr(e,t){try{if((await e.next()).done)return;await Promise.resolve(t?.interruptGenerate())}catch{return}await Mr(e)}function Fr(e,t){return t?t.aborted?Promise.reject(new q(`AI request aborted by caller`,`AI_ABORTED`,Y)):new Promise((n,r)=>{let i=()=>r(new q(`AI request aborted by caller`,`AI_ABORTED`,Y));t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,i),n(e)},e=>{t.removeEventListener(`abort`,i),r(e)})}):e}var Ir={createWorker:()=>new Worker(new URL(new URL(`../workers/llm.worker-BYu-MLm1.js`,import.meta.url).href,``+import.meta.url),{type:`module`}),createEngine:async(e,t,n)=>{let{CreateWebWorkerMLCEngine:r}=await c(async()=>{let{CreateWebWorkerMLCEngine:e}=await import(`./DL8aLXmX.js`);return{CreateWebWorkerMLCEngine:e}},[],import.meta.url);return r(e,t,{initProgressCallback:e=>n(e)})}};async function Lr(e,t,n,r=Ir){if(n?.aborted)throw new DOMException(`Cancelled`,`AbortError`);let i=r.createWorker(),a=()=>i.terminate(),o,s=new Promise((e,t)=>{o=()=>{a(),t(new DOMException(`Cancelled`,`AbortError`))},n?.addEventListener(`abort`,o,{once:!0})});try{return{engine:await Promise.race([r.createEngine(i,e,t),s]),dispose:a}}catch(e){throw a(),e}finally{o&&n?.removeEventListener(`abort`,o)}}var Rr=e=>!!e&&typeof e==`object`&&e.kind===`cookbook-offer`&&typeof e.offerId==`string`,zr=class{find;#e=n(i({}));get offers(){return e(this.#e)}set offers(e){s(this.#e,e,!0)}applier=null;counter=0;constructor(e){this.find=e}pending(){return Object.values(this.offers).find(e=>e.status===`pending`)}engaged(){return Object.values(this.offers).some(e=>e.status===`pending`||e.status===`applied`)}offer(e){let t=this.pending();if(t?.cookbookId===e)return null;t&&(t.status=`replaced`);let n=`offer-${++this.counter}`;return this.offers[n]={id:n,cookbookId:e,status:`pending`,error:``},{kind:`cookbook-offer`,offerId:n}}accept(e){let t=this.offers[e];if(t?.status!==`pending`)return;let n=this.find(t.cookbookId),r=n?this.applier?this.applier(n):`Not ready yet.`:`Unknown cookbook.`;r||!n?(t.status=`failed`,t.error=r??`Could not set it up.`):t.status=`applied`}decline(e){let t=this.offers[e];t?.status===`pending`&&(t.status=`declined`)}},Br=`smrt-planner:assistant:v1`;function Vr(){return{modelId:rr,consented:[]}}function Hr(e){let t=Vr();try{let n=e?.getItem(Br);if(!n)return t;let r=JSON.parse(n);typeof r.modelId==`string`&&ar(r.modelId)&&(t.modelId=r.modelId),Array.isArray(r.consented)&&(t.consented=r.consented.filter(e=>typeof e==`string`&&!!ar(e)))}catch{}return t}function Ur(e,t){try{e?.setItem(Br,JSON.stringify(t))}catch{}}var Wr=e=>!!e&&typeof e==`object`&&e.kind===`theme-undo`&&typeof e.undoId==`string`,Gr=class{store;controller;#e=n(i({}));get undos(){return e(this.#e)}set undos(e){s(this.#e,e,!0)}counter=0;constructor(e,t){this.store=e,this.controller=t}record(e,n){let r=`theme-undo-${++this.counter}`;return this.undos[r]={id:r,previous:e?structuredClone(t(e)):void 0,status:`available`,...n?{commandUndoId:n}:{}},{kind:`theme-undo`,undoId:r}}undo(e){let t=this.undos[e];t?.status===`available`&&(t.commandUndoId&&this.controller?.run({name:`undo`,input:{undoId:t.commandUndoId}}).ok||this.store.write(t.previous),t.status=`undone`)}};function Kr(e,t=[],n=!1,r=!1,i=[]){let a=e.map(e=>e.id),o={type:`array`,items:{enum:a},maxItems:a.length},s={reply:{type:`string`,maxLength:200},add:o,remove:o};return t.length&&(s.cookbook={enum:[...t.map(e=>e.id),null]}),n&&(s.settings={type:`object`,properties:{currency:{type:`string`,pattern:`^[A-Z]{3}$`},taxRate:{type:`number`,minimum:0,maximum:100},paymentTerms:{type:`string`,maxLength:40},pricesIncludeTax:{type:`boolean`},taxRounding:{enum:[`line`,`document`]}},additionalProperties:!1}),r&&(s.theme={type:`object`,properties:{preset:{enum:[...x]},primary:{type:`string`,pattern:`^#[0-9a-fA-F]{6}$`},colorScheme:{enum:[`light`,`dark`]},borderRadius:{enum:[...S]},density:{enum:[...T]},contrast:{enum:[...E]}},additionalProperties:!1}),i.length&&(s.open={enum:[...i,null]}),{type:`object`,properties:s,required:[`reply`,`add`,`remove`],additionalProperties:!1}}function qr(e){let t={};if(!e||typeof e!=`object`||Array.isArray(e))return t;let n=e;if(typeof n.currency==`string`){let e=n.currency.trim().toUpperCase();Cn.has(e)&&(t.currency=e)}let r=n.taxRate;if(typeof r==`number`&&Number.isFinite(r)&&r>=0&&r<=100&&(t.taxRate=r),typeof n.paymentTerms==`string`){let e=[...n.paymentTerms].map(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127?` `:e).join(``).trim();e&&e.length<=40&&(t.paymentTerms=e)}return typeof n.pricesIncludeTax==`boolean`&&(t.pricesIncludeTax=n.pricesIncludeTax),(n.taxRounding===`line`||n.taxRounding===`document`)&&(t.taxRounding=n.taxRounding),t}function Jr(e){let t={};if(!e||typeof e!=`object`||Array.isArray(e))return t;let n=e;typeof n.preset==`string`&&x.includes(n.preset)&&(t.preset=n.preset);let r=_(n.primary);return r&&(t.primary=r),(n.colorScheme===`light`||n.colorScheme===`dark`||n.colorScheme===`system`)&&(t.colorScheme=n.colorScheme),S.includes(n.borderRadius)&&(t.borderRadius=n.borderRadius),T.includes(n.density)&&(t.density=n.density),E.includes(n.contrast)&&(t.contrast=n.contrast),t}function Yr(e){return e.replace(/<think>[\s\S]*?<\/think>/gi,``).replace(/<think>[\s\S]*$/i,``).trim()}function Xr(e){let t=/"reply"\s*:\s*"((?:[^"\\]|\\.)*)/.exec(e);if(!t)return null;let n=t[1];n=n.replace(/\\$/,``);try{n=JSON.parse(`"${n}"`)}catch{n=n.replace(/\\n/g,` `).replace(/\\"/g,`"`)}return n.trim()||null}function Zr(e,t,n=[],r={}){let i=new Set(t.map(e=>e.id)),a=Yr(e),o=e=>({reply:e,add:[],remove:[],cookbook:null,settings:{},theme:{}}),s=/^[\s`]*[{[]/.test(a)||/"reply"\s*:/.test(a),c=()=>o(s?Xr(a)??`Sorry, say that again?`:a),l;try{l=JSON.parse(a)}catch{return c()}if(!l||typeof l!=`object`||Array.isArray(l))return c();let u=l,d=e=>Array.isArray(e)?[...new Set(e.filter(e=>typeof e==`string`&&i.has(e)))]:[],f=d(u.add),p=d(u.remove),m=new Set(f.filter(e=>p.includes(e))),h=r.commands?Qr(u.commands):[];return{reply:typeof u.reply==`string`?u.reply.trim():``,add:f.filter(e=>!m.has(e)),remove:p.filter(e=>!m.has(e)),cookbook:typeof u.cookbook==`string`&&n.some(e=>e.id===u.cookbook)?u.cookbook:null,settings:qr(u.settings),theme:Jr(u.theme),...h.length?{commands:h}:{},...typeof u.open==`string`&&r.sections?.includes(u.open)?{open:u.open}:{}}}function Qr(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(t.length>=8)break;if(!n||typeof n!=`object`)continue;let{name:e,input:r}=n;typeof e==`string`&&t.push({name:e,input:r??{}})}return t}function $r(e,t){let n=e=>t.find(t=>t.id===e),r=e=>n(e)?.label??e,i=e=>e.map(r).join(`, `),a=[];e.added.length&&a.push(`Added ${i(e.added)}.`);let o=e.added.filter(e=>n(e)?.nav?.length===0);return o.length&&a.push(`${i(o)} ${o.length===1?`adds`:`add`} nothing to the menu.`),e.removed.length&&a.push(`Removed ${i(e.removed)}.`),e.kept.length&&a.push(`Kept ${i(e.kept)} (needed).`),a.join(` `)}var ei={name:10,synonym:6,keyword:4},ti=1.5,ni=new Set([`a`,`an`,`and`,`the`,`of`,`for`,`to`,`in`,`on`,`or`,`general`,`simple`]),ri=[`car`,`vehicle`,`metal`,`steel`,`gates`,`studio`,`classes`,`members`,`shop`,`order`,`item`,`material`,`customer`,`sales`,`stock`,`schedule`,`terms`];function ii(e){return e.length<=3?e:e.endsWith(`ies`)?`${e.slice(0,-3)}y`:e.endsWith(`sses`)?e.slice(0,-2):/(us|ss|is)$/.test(e)?e:e.endsWith(`s`)?e.slice(0,-1):e}function ai(e){return e.normalize(`NFD`).replace(/\p{M}/gu,``).toLowerCase().replace(/['’]s\b/g,``).replace(/['’]/g,``).replace(/[^a-z0-9]+/g,` `).trim().split(` `).filter(Boolean).map(ii).join(` `)}var oi=new Set(ri.map(ai)),si={"commerce.customers":[`customer`,`client`,`contacts`,`patrons`],"commerce.purchases":[`purchase`,`buy supplies`,`reorder`,`order from suppliers`],"commerce.sales":[`sell`,`sale`,`sales order`,`point of sale`],"commerce.vendors":[`vendor`,`supplier`,`who we buy from`],"inventory.stock":[`inventory`,`track stock`,`stock levels`,`warehouse`,`count stock`],"products.simple":[`product`,`price list`,`menu`,`things we sell`],"products.clothing":[`clothes`,`shirts`,`fashion`,`sizes and colours`],"products.ingredients":[`ingredient`,`recipe`,`raw material`,`flour`,`components`],"commerce.estimates":[`estimate`,`quote`,`quotes for customers`,`price quote`,`bid`],"commerce.wholesale":[`wholesale`,`bulk`,`trade customers`,`resellers`],"commerce.invoicing":[`invoice`,`send invoices`,`bill customers`,`get paid`,`receipts`],"commerce.fulfillment":[`ship`,`shipping`,`courier`,`parcels`,`deliver`],"commerce.agreements":[`contract`,`agreement`,`sign contracts`],"commerce.leases":[`lease`,`rent out`,`equipment hire`],"commerce.licenses":[`licence`,`licence sales`,`software licenses`],"ledgers.bookkeeping":[`books`,`keep the books`,`bookkeeper`,`accountant`,`expenses`],"projects.tracker":[`project`,`task`,`to do list`,`bug`,`ticket`],"events.calendar":[`appointment`,`schedule appointments`,`event`,`meeting`,`reservation`],"sales.pipeline":[`lead`,`pipeline`,`prospect`,`follow up`,`sales funnel`]};function ci(e,t){let n=ai(e);if(!n)return null;let r=n.split(` `);return r.length===1&&ni.has(n)?null:{text:n,tier:t,weak:t!==`name`&&r.every(e=>oi.has(e)),words:r.length}}function Z(e,t,n){let r=ci(t,n);if(!r)return;let i=e.terms.find(e=>e.text===r.text);i?ei[r.tier]>ei[i.tier]&&(i.tier=r.tier,i.weak=r.weak):e.terms.push(r)}function li(e){return ai(e).split(` `).filter(e=>e&&!ni.has(e))}var ui=[`theme`,`colour`,`color`,`colour scheme`,`dark mode`,`light mode`,`brand`,`branding`,`style`,`warmer`,`cooler`,`font`];function di(e,t=[],n={}){let r=[];for(let t of e){let e={kind:`recipe`,id:t.id,terms:[],exact:ai(t.label)};Z(e,t.label,`name`),Z(e,(t.id.split(`.`).pop()??``).replace(/[-_]/g,` `),`name`);for(let n of li(t.label))Z(e,n,`synonym`);for(let n of t.synonyms)Z(e,n,`synonym`);for(let n of si[t.id]??[])Z(e,n,`keyword`);r.push(e)}for(let e of t){let t={kind:`cookbook`,id:e.id,terms:[],exact:ai(e.name)};Z(t,e.name,`name`),Z(t,e.id.replace(/[-_]/g,` `),`name`);for(let n of e.keywords??[])Z(t,n,`keyword`);r.push(t)}if(n.theme){let e={kind:`theme`,id:`theme`,terms:[]};for(let t of ui)Z(e,t,`keyword`);r.push(e)}return{entries:r}}function fi(e,t){let n=ai(t),r=` ${n} `,i=[];for(let t of e.entries){let e=0,a=!1,o=[];for(let n of t.terms)r.includes(` ${n.text} `)&&(o.push(n.text),e+=ei[n.tier]*(n.words>1?ti:1)*(n.weak?.5:1),n.weak||(a||=!0));o.length&&(t.exact&&t.exact===n&&(e+=1),i.push({kind:t.kind,id:t.id,score:e,confidence:a?`strong`:`weak`,terms:o}))}return i.sort((e,t)=>t.score-e.score||e.id.localeCompare(t.id))}var pi=5,mi=2,hi=[{says:`I run a bakery`,cookbook:`bakery`,answer:{reply:`The Bakery cookbook covers that.`,add:[],remove:[],cookbook:`bakery`}},{says:`I need to send invoices`,recipes:[`commerce.invoicing`],answer:{reply:`Added invoicing for billing customers.`,add:[`commerce.invoicing`],remove:[]}},{says:`we don't need the pipeline`,recipes:[`sales.pipeline`],answer:{reply:`Removed leads and pipeline.`,add:[],remove:[`sales.pipeline`]}},{says:`we're in Canada, 13% tax`,settings:!0,answer:{reply:`Set to Canadian dollars and 13% tax.`,add:[],remove:[],settings:{currency:`CAD`,taxRate:13}}},{says:`make it warmer`,theme:!0,answer:{reply:`Gave it a warm amber brand colour.`,add:[],remove:[],theme:{primary:`#d97706`}}},{says:`hello`,answer:{reply:`Hi. What kind of business is it?`,add:[],remove:[]}}];function gi(e,t,n,r){return hi.filter(i=>(i.recipes??[]).every(t=>e.has(t))&&(!i.cookbook||t.has(i.cookbook))&&(!i.settings||n)&&(!i.theme||r)).map(e=>`"${e.says}" -> ${JSON.stringify(e.answer)}`)}var _i=`reports.runtime`;function vi(e){return`${Number((e*100).toFixed(4))}%`}function yi(e,t,n=[],r,i,a,o=[]){let s=i!==void 0,c=(i??[]).filter(e=>e.kind===`recipe`).slice(0,pi).map(e=>e.id),l=(i??[]).filter(e=>e.kind===`cookbook`).slice(0,mi).map(e=>e.id),u=new Set([...c,...t]),d=new Set(l),f=e=>{let t=e.synonyms.length?` Also called: ${e.synonyms.join(`, `)}.`:``;return`- ${e.id}: ${e.label}. ${e.summary}${t}`},p=[`You help assemble a small business app. Reply as JSON.`,`"reply": answer what they just said in one sentence of 12 words or fewer. No greeting; never repeat a reply.`,`"add"/"remove": recipe ids, only what they ask to add or drop; else []. Dependencies are automatic.`];n.length&&p.push(`"cookbook": id only if their business clearly fits, else null.`),r&&p.push(`"settings": only what they state: currency (ISO), taxRate (percent), paymentTerms, pricesIncludeTax (true when their prices include tax), taxRounding (line|document); else omit, and do not mention them otherwise.`),a&&p.push(`"theme": only if they ask for a look: {"preset": material|glass|studio|smrt|happyvertical} or {"primary": "#rrggbb"}, optional "colorScheme": light|dark, "borderRadius": none|sm|md|lg|xl|full, "density": comfortable|touch, "contrast": auto|standard|more; else omit.`),o.length&&p.push(`"open": a menu section id only when they ask to see or go to one, else null.`),p.push(`"reply" never claims anything beyond add, remove, cookbook, settings, theme and open: the app reports what changed.`),e.some(e=>e.id===`reports.runtime`)&&p.push(`A report or summary of their data needs ${_i} (Reports): add it, and open only its section, never another. You cannot build the report itself yet.`);let m=gi(new Set(e.map(e=>e.id)),new Set(n.map(e=>e.id)),!!r,!!a);m.length&&p.push(``,`Examples:`,...m);let h=!!a&&(i??[]).some(e=>e.kind===`theme`);if(c.length||l.length||h){let e=[];h&&e.push(`theming (use "theme")`),l.length&&e.push(`cookbook ${l.join(`, `)}`),c.length&&e.push(`recipes ${c.join(`, `)}`),p.push(``,`Looks relevant: ${e.join(`; `)}.`)}let g=e=>`- ${e.id}: ${e.name}. ${e.summary}`,_=e=>e.join(`, `),v=e.filter(e=>!s||u.has(e.id)),y=s?e.filter(e=>!u.has(e.id)):[];if(p.push(``),v.length&&p.push(`Recipes:`,...v.map(f)),y.length&&p.push(`Other recipes: ${_(y.map(e=>`${e.id} (${e.label})`))}.`),n.length){let e=n.filter(e=>!s||d.has(e.id)),t=s?n.filter(e=>!d.has(e.id)):[];p.push(``),e.length&&p.push(`Cookbooks:`,...e.map(g)),t.length&&p.push(`Other cookbooks: ${_(t.map(e=>`${e.id} (${e.name})`))}.`)}if(p.push(``,`Currently on: ${t.length?t.join(`, `):`none`}.`),r){let e=r.paymentTerms?`, terms ${r.paymentTerms}`:``,t=r.pricesIncludeTax?`, prices include tax`:`, prices exclude tax`,n=r.taxRounding===`document`?`, tax rounded per document`:``;p.push(`Settings: currency ${r.currency}, tax ${vi(r.taxRate)}${e}${t}${n}.`)}return a&&p.push(`Theme: ${b(a.current)}.`),o.length&&p.push(`Menu: ${o.map(e=>`${e.id} (${e.label})`).join(`, `)}.`),p.join(`
24
- `)}var bi=`Plan your app`,xi=`What would you like to build?`,Si=400,Ci=e=>Object.keys(e).length>0;function wi(e,t,n){let r=e.run({name:t,input:n});return r.ok?{summary:r.receipt.summary,undoId:r.receipt.undoId}:{summary:``}}var Ti=(e,t,n)=>wi(e,t,n).summary;function Ei(e,t){let n=[];for(let r of t){let t=e.run(r);if(!t.ok){n.push(`The server's ${r.name} was refused: ${t.error.message}`);break}t.receipt.summary&&n.push(t.receipt.summary)}return n.join(` `)}var Di=`Nothing in the app changed.`,Oi=`Building the report itself is not available in the planner yet; it will live under Reports.`,ki=`item:reports:RuntimeReport`;function Ai(e,t,n){return t||(n||e.trim().endsWith(`?`)?e:[e,Di].filter(Boolean).join(` `))}function ji(e,t,n){let r=n.find(e=>e.id===t)?.label??t,i=e.run({name:`focus`,input:{section:t}});return i.ok?`Opened ${r}.`:`Could not open ${r}: ${i.error.message}`}function Mi(e,t){let n=t.add.length?e.run({name:`add_recipes`,input:{ids:t.add}}):null,r=t.remove.length?e.run({name:`remove_recipes`,input:{ids:t.remove}}):null,i=n?.ok?n.receipt.changes?.added??[]:[],a=r?.ok?r.receipt.changes?.removed??[]:[];return{added:i.filter(e=>!a.includes(e)),removed:a.filter(e=>!i.includes(e)),kept:r?.ok?r.receipt.changes?.kept??[]:[]}}function Ni(e){let t=e.now??(()=>Date.now()),n=0,r=e=>`${e}-${++n}`,i={id:`planner`,title:bi,isResolved:!1,messageCount:0,lastMessageAt:null},a=[],o=new Map,s=null,c=(e,n,o,s)=>{let c={id:r(`m`),threadId:i.id,content:n,role:e,createdAt:new Date(t()),...o?{clientRequestId:o}:{}};return s&&(c.toolCallData=s),a.push(c),i.messageCount=a.length,i.lastMessageAt=c.createdAt,c},l=e.controller??Zn({store:e.store,settings:e.settings,theme:e.theme}),u=di(e.recipes,e.cookbooks??[],{theme:!!e.theme}),d=c(`assistant`,xi);async function f(t){let n=e.model();if(!n)return{content:(typeof e.unavailable==`function`?e.unavailable():e.unavailable)??`Download a model first, then I can help. The cards on the Planner page work without one.`};s=new AbortController;try{let r=e.cookbooks??[],i=a.filter(e=>e!==d).slice(0,-1).slice(-6).map(e=>({role:e.role,content:e.content})),o=fi(u,t),c=e.menu?.()??[],f=Zr(await n.message(t,{history:[{role:`system`,content:yi(e.recipes,e.store.ids,r,e.settings?.read(),o,e.theme?{current:e.theme.read()}:void 0,c)},...i],responseSchema:Kr(e.recipes,r,!!e.settings,!!e.theme,c.map(e=>e.id)),temperature:0,maxTokens:Si,signal:s.signal}),e.recipes,r,{commands:typeof e.acceptCommands==`function`?e.acceptCommands():e.acceptCommands,sections:c.map(e=>e.id)}),p=Mi(l,f),m=e.settings&&Ci(f.settings)?Ti(l,`set_settings`,f.settings):``,h=e.theme?.read(),g=e.theme&&Ci(f.theme)?wi(l,`set_theme`,f.theme):null,_=g?.undoId&&e.themeUndos?e.themeUndos.record(h,g.undoId):void 0,v=(f.commands??[]).length?Ei(l,f.commands??[]):``,y=o.some(e=>e.kind===`recipe`&&e.id===`reports.runtime`),b=l.snapshot().sections.find(e=>e.items.some(e=>e.id===ki))?.id,x=f.open&&(!y||f.open===b)?f.open:void 0,S=x?ji(l,x,c):``,C=[$r(p,e.recipes),m,g?.summary??``,v,S].filter(Boolean).join(` `),w=o.find(e=>e.kind===`cookbook`&&e.confidence===`strong`)?.id,T=f.cookbook??(w&&e.offers?.engaged?.()===!1?w:null),E=T?e.offers?.offer(T)??void 0:void 0,D=E?r.find(e=>e.id===T):void 0,O=[Ai(f.reply||(D?`Set up ${D.name}?`:``),C,!!E),y?Oi:``].filter(Boolean).join(` `);return O&&e.onReply?.(O),{content:O,refs:E&&_?[E,_]:E??_}}catch(e){return s?.signal.aborted?{content:`Stopped.`}:{content:`Sorry, the model could not answer: ${e instanceof Error?e.message:String(e)}`}}finally{s=null}}return{async listThreads(){return[i]},async createThread(){return i},async loadMessages(){return[...a]},async sendMessage(e){let t=o.get(e.clientRequestId);if(t)return t;let n=c(`user`,e.content,e.clientRequestId),r=await f(e.content),i={inProgress:!1,userMessage:n,assistantMessage:c(`assistant`,r.content,void 0,r.refs)};return o.set(e.clientRequestId,i),i},async uploadAttachment(e){throw Error(`The assistant cannot take attachments (${e.name}).`)},abort(){s?.abort()}}}function Pi(e,t){return/^qwen3/i.test(t)?{message:(t,n)=>e.message(`${t} /no_think`,n)}:e}var Fi=class{#e=n(`idle`);get status(){return e(this.#e)}set status(e){s(this.#e,e,!0)}#t=n(i({modelId:``,consented:[]}));get prefs(){return e(this.#t)}set prefs(e){s(this.#t,e,!0)}#n=n(i({progress:0,text:``}));get progress(){return e(this.#n)}set progress(e){s(this.#n,e,!0)}#r=n(``);get error(){return e(this.#r)}set error(e){s(this.#r,e,!0)}#i=n(`browser`);get mode(){return e(this.#i)}set mode(e){s(this.#i,e,!0)}#a=n(``);get remoteLabel(){return e(this.#a)}set remoteLabel(e){s(this.#a,e,!0)}transport;offers=new zr(re);themeUndos;loaded=null;chat=null;abort=null;loadGeneration=0;options;constructor(e){this.options=e,this.prefs=Hr(e.storage),this.status=(e.webgpu??kr)()?`idle`:`unsupported`,this.themeUndos=e.theme?new Gr(e.theme,e.controller):null,this.transport=Ni({model:()=>this.chat,store:e.store,recipes:e.recipes,cookbooks:k,offers:this.offers,settings:e.settings,theme:e.theme,controller:e.controller,themeUndos:this.themeUndos??void 0,acceptCommands:()=>this.mode===`host`,unavailable:()=>this.mode===`byo`?`Connect your model on the AI page first, then I can help. The cards on the Planner page work without one.`:this.mode===`host`?`The assistant is not available right now. The cards on the Planner page work without it.`:this.mode===`manual`?`Inference is off. The cards on the Planner page work without it.`:`Download a model first, then I can help. The cards on the Planner page work without one.`,onReply:t=>e.onReply?.(t),menu:e.menu})}setMode(e){e!==this.mode&&this.unload(),this.mode=e,this.status=e===`browser`?(this.options.webgpu??kr)()?`idle`:`unsupported`:`idle`}useRemote(e,t){this.mode!==`browser`&&(this.chat=e,this.remoteLabel=e?t:``,this.status=e?`ready`:`idle`)}get consented(){return this.prefs.consented.includes(this.prefs.modelId)}select(e){ar(e)&&this.status!==`loading`&&(this.prefs={...this.prefs,modelId:e},Ur(this.options.storage,this.prefs))}async start(){if(this.status===`loading`||this.status===`unsupported`)return;let e=this.prefs.modelId;if(!ar(e))return;this.status=`loading`,this.error=``,this.progress={progress:0,text:`Starting`};let t=new AbortController,n=++this.loadGeneration;this.abort=t;try{let r=await Lr(e,e=>{this.progress=e},t.signal,this.options.host??Ir);if(n!==this.loadGeneration||this.mode!==`browser`){r.dispose();return}this.loaded=r,this.prefs={...this.prefs,consented:[...new Set([...this.prefs.consented,e])]},Ur(this.options.storage,this.prefs),this.chat=Pi(new jr({type:`webllm`,engine:r.engine,model:e}),e),this.status=`ready`}catch(e){if(n!==this.loadGeneration)return;t.signal.aborted?this.status=`idle`:(this.error=e instanceof Error?e.message:String(e),this.status=`error`)}finally{n===this.loadGeneration&&(this.abort=null)}}cancel(){this.abort?.abort()}unload(){this.loadGeneration+=1;let e=this.abort;this.abort=null,e?.abort(),this.transport.abort(),this.loaded?.dispose(),this.loaded=null,this.chat=null,this.status!==`unsupported`&&(this.status=`idle`)}},Ii=[{id:`moonshine-base`,label:`Moonshine base`,note:`Accurate and still quick, best for talking as you go (default)`,adapter:`moonshine`,bytes:p[`moonshine-base`]?.bytes??0},{id:`moonshine-tiny`,label:`Moonshine tiny`,note:`Fastest, less accurate`,adapter:`moonshine`,bytes:p[`moonshine-tiny`]?.bytes??0},{id:`whisper-tiny.en`,label:`Whisper tiny`,note:`English, the original choice`,adapter:`whisper-local`,bytes:p[`whisper-tiny.en`]?.bytes??0}],Li=`moonshine-base`;function Ri(e){return Ii.find(t=>t.id===e)??Ii[0]}var zi=`smrt-planner:voice:v1`;function Bi(e){try{let t=e?.getItem(zi);if(t){let e=JSON.parse(t),n=e.local===!0,r=Ii.find(t=>t.id===e.model)?.id;return{local:n,preferLocal:e.preferLocal===!0,model:r??(n?`whisper-tiny.en`:`moonshine-base`)}}}catch{}return{local:!1,preferLocal:!1,model:Li}}function Vi(e,t){try{e?.setItem(zi,JSON.stringify(t))}catch{}}function Hi(e){return Bi(e).local}function Ui(e,t){Vi(e,{...Bi(e),local:t})}function Wi(e){return Bi(e).preferLocal}function Gi(e){return Bi(e).model}function Ki(e,t,n){return e===`works`?`browser`:t&&n?`enable-cached`:`offer`}var qi=class{#e=n(`checking`);get status(){return e(this.#e)}set status(e){s(this.#e,e,!0)}#t=n(!1);get cached(){return e(this.#t)}set cached(e){s(this.#t,e,!0)}#n=n(0);get progress(){return e(this.#n)}set progress(e){s(this.#n,e,!0)}#r=n(``);get error(){return e(this.#r)}set error(e){s(this.#r,e,!0)}#i=n(!1);get browserWorks(){return e(this.#i)}set browserWorks(e){s(this.#i,e,!0)}#a=n(!1);get preferLocal(){return e(this.#a)}set preferLocal(e){s(this.#a,e,!0)}#o=n(0);get size(){return e(this.#o)}set size(e){s(this.#o,e,!0)}#s=n(Li);get model(){return e(this.#s)}set model(e){s(this.#s,e,!0)}#c=n(!1);get preparing(){return e(this.#c)}set preparing(e){s(this.#c,e,!0)}#l=n(null);get dictation(){return e(this.#l)}set dictation(e){s(this.#l,e)}handle=null;abort=null;options;generation=0;constructor(e){this.options=e}async init(){let e=++this.generation;try{await this.probeAndOffer(e)}catch(t){if(e!==this.generation)return;this.status=`error`,this.error=t instanceof Error?t.message:String(t)}}async probeAndOffer(e){let t=await(this.options.probe??ie)();if(e!==this.generation)return;this.browserWorks=t===`works`,this.preferLocal=Wi(this.options.storage),this.model=Gi(this.options.storage);let n=this.preferLocal&&t===`works`?`unreliable`:t;if(n===`works`){this.dictation=(this.options.browserSource??(()=>f({type:`browser-speech`})))(),this.status=`browser`;return}let r=this.options.createModel(this.model);this.handle?.dispose(),this.handle=r,this.size=r.estimateSize();let i=await r.isCached().catch(()=>!1);e===this.generation&&(this.cached=i,Ki(n,Hi(this.options.storage),this.cached)===`enable-cached`?await this.enable():this.status=`offer`)}async enable(){let e=this.handle;if(!e||this.status===`downloading`)return;let t=++this.generation;this.status=`downloading`,this.error=``,this.progress=0,this.preparing=!1;let n=new AbortController;this.abort=n;try{if(await e.load({onProgress:e=>{t===this.generation&&(this.progress=e.bytesTotal>0?e.bytesLoaded/e.bytesTotal:0,this.preparing=e.state===`extracting`)},signal:n.signal}),t!==this.generation)return;Ui(this.options.storage,!0),this.cached=!0;let r=Ri(this.model);this.dictation=(this.options.localSource??((e,t)=>f({type:t.adapter,modelHandle:e})))(e,r),this.status=`ready`}catch(e){if(t!==this.generation)return;n.signal.aborted?this.status=`offer`:(this.error=e instanceof Error?e.message:String(e),this.status=`error`)}finally{t===this.generation&&(this.abort=null,this.preparing=!1)}}async setPreferLocal(e){this.browserWorks&&e!==this.preferLocal&&await this.restart({preferLocal:e})}async setModel(e){e!==this.model&&Ii.some(t=>t.id===e)&&await this.restart({model:e})}async restart(e){this.generation++,this.abort?.abort(),this.abort=null,this.preparing=!1,this.handle?.dispose(),this.handle=null,this.dictation=null,Vi(this.options.storage,{...Bi(this.options.storage),...e}),this.status=`checking`,await this.init()}cancel(){this.abort?.abort()}dismiss(){this.status=`dismissed`}dispose(){this.generation++,this.abort?.abort(),this.handle?.dispose(),this.handle=null,this.dictation=null}},Ji=[`json_schema`,`json_object`,`none`],Yi=12e4;function Q(e){try{let t=new URL(e.trim());if(t.protocol!==`http:`&&t.protocol!==`https:`||t.username||t.password)return null;for(let e of t.searchParams.keys())if(/^(?:api[-_]?key|key|token|authorization|secret|password)$/i.test(e))return null;return`${t.origin}${t.pathname.replace(/\/+$/,``)}`}catch{return null}}function Xi(e){let t=e.toLowerCase().replace(/^\[|\]$/g,``);return t===`localhost`||t.endsWith(`.localhost`)||t===`::1`||/^127(\.\d{1,3}){3}$/.test(t)}function Zi(e){try{let t=new URL(e.trim());return t.protocol===`https:`||t.protocol===`http:`&&Xi(t.hostname)}catch{return!1}}function Qi(e){try{return new URL(e.trim()).origin}catch{return null}}var $i=class extends Error{status;constructor(e,t){super(e),this.status=t,this.name=`EndpointError`}};function ea(e){return e===401||e===403?`the endpoint refused the key (${e})`:e===404?`the endpoint or model was not found (404), check the address and model name`:e===429?`the endpoint is rate limiting you (429)`:`the endpoint answered ${e}`}function ta(e){let t=(e?.choices?.[0])?.message?.content;if(typeof t==`string`)return t;if(Array.isArray(t))return t.map(e=>e&&typeof e==`object`&&`text`in e?String(e.text):``).join(``);throw new $i(`the endpoint sent no reply text`)}function na(e,t){if(e!==`none`)return e===`json_schema`&&t&&typeof t==`object`?{type:`json_schema`,json_schema:{name:`planner_turn`,strict:!1,schema:t}}:{type:`json_object`}}function ra(e){let t=Q(e.baseUrl);if(!t)throw new $i(`the address is not a valid http(s) URL`);if(e.apiKey&&!Zi(t))throw new $i(`a key is only sent over https, or to this computer; use an https address`);let n=`${t}/chat/completions`,r=e.fetch??fetch,i=Math.max(0,Ji.indexOf(e.jsonMode??`json_schema`));async function a(t,i){let a=AbortSignal.timeout(Yi);try{return await r(n,{method:`POST`,headers:{"content-type":`application/json`,...e.apiKey?{authorization:`Bearer ${e.apiKey}`}:{}},body:JSON.stringify(t),credentials:`omit`,signal:i?AbortSignal.any([i,a]):a})}catch(e){throw i?.aborted?e:new $i(`could not reach the endpoint. Is it running, and does it allow this page (CORS)?`)}}async function o(t,n={}){let r=n.json!==!1;for(;;){let o=r?Ji[i]??`none`:`none`,s=na(o,n.schema),c=await a({model:e.model,messages:t,stream:!1,temperature:n.temperature??0,...n.maxTokens?{max_tokens:n.maxTokens}:{},...s?{response_format:s}:{}},n.signal);if(c.ok)return r&&e.onJsonMode?.(o),ta(await c.json().catch(()=>null));if(r&&(c.status===400||c.status===422)&&i<Ji.length-1)i+=1;else throw new $i(ea(c.status),c.status)}}return{complete:o,message(e,t){return o([...(t?.history??[]).map(({role:e,content:t})=>({role:e,content:t})),{role:`user`,content:e}],{maxTokens:t?.maxTokens,signal:t?.signal,temperature:t?.temperature,schema:t?.responseSchema})}}}async function ia(e){try{return{ok:!0,message:(await ra({...e,jsonMode:`none`}).complete([{role:`user`,content:`Reply with the single word OK.`}],{maxTokens:8,json:!1})).trim()?`Connected to ${e.model}.`:`Connected to ${e.model}, but it sent an empty reply.`}}catch(e){return{ok:!1,message:e instanceof $i?`Could not connect: ${e.message}.`:`Could not connect.`}}}var aa=[{id:`ollama`,label:`Ollama (on this computer)`,baseUrl:`http://localhost:11434/v1`,model:`llama3.2`,keyless:!0,cors:`Ollama only answers pages it trusts. Start it with OLLAMA_ORIGINS set to this site, for example OLLAMA_ORIGINS=https://your-site.example ollama serve (on macOS: launchctl setenv OLLAMA_ORIGINS https://your-site.example, then restart Ollama). A page served from http://localhost needs no change.`},{id:`openrouter`,label:`OpenRouter`,baseUrl:`https://openrouter.ai/api/v1`,model:`openai/gpt-4o-mini`,cors:`OpenRouter accepts calls from any web page, so no setup is needed. Use a key with a spending limit.`},{id:`openai`,label:`OpenAI`,baseUrl:`https://api.openai.com/v1`,model:`gpt-4o-mini`,cors:`OpenAI accepts calls from web pages when the request carries a key. Use a restricted key with a low spending limit: anyone with access to this browser profile can read it.`},{id:`custom`,label:`Custom OpenAI-compatible endpoint`,baseUrl:``,customUrl:!0,cors:`The server must answer the browser's CORS preflight: allow this site's origin, the "authorization" and "content-type" headers, and the POST and OPTIONS methods.`}];function oa(e){if(!e?.length)return[...aa];let t=[];for(let n of e){let e=typeof n==`string`?aa.find(e=>e.id===n):n;e&&!t.some(t=>t.id===e.id)&&t.push(e)}return t.length?t:[...aa]}var sa=`smrt-planner:inference:v1`,ca=`smrt-planner:inference-key:v1`,la=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function ua(e){let t={preset:``,active:!1,entries:{}};try{let n=e?.getItem(sa);if(!n)return t;let r=JSON.parse(n);if(!la(r))return t;typeof r.preset==`string`&&(t.preset=r.preset),t.active=r.active===!0;let i=!1;if(la(r.entries)){for(let[e,n]of Object.entries(r.entries))if(la(n)&&typeof n.baseUrl==`string`&&typeof n.model==`string`){let r=Q(n.baseUrl)??``;i||=r!==n.baseUrl,t.entries[e]={baseUrl:r,model:n.model}}}i&&(t.active=!1,e?.setItem(sa,JSON.stringify(t)))}catch{}return t}function da(e){let t={};try{let n=e?.getItem(ca),r=n?JSON.parse(n):null;if(la(r))for(let[e,n]of Object.entries(r))la(n)&&typeof n.key==`string`&&n.key&&typeof n.origin==`string`&&n.origin&&(t[e]={origin:n.origin,key:n.key})}catch{}return t}var fa=class{presets;#e=n(``);get presetId(){return e(this.#e)}set presetId(e){s(this.#e,e,!0)}#t=n(i({}));get entries(){return e(this.#t)}set entries(e){s(this.#t,e,!0)}#n=n(i({}));get keys(){return e(this.#n)}set keys(e){s(this.#n,e,!0)}#r=n(!1);get active(){return e(this.#r)}set active(e){s(this.#r,e,!0)}#i=n(`idle`);get testStatus(){return e(this.#i)}set testStatus(e){s(this.#i,e,!0)}#a=n(``);get testMessage(){return e(this.#a)}set testMessage(e){s(this.#a,e,!0)}options;credentialStorage;constructor(e){if(this.options=e,this.credentialStorage=e.credentialPersistence===`memory`?null:e.storage,e.credentialPersistence===`memory`)try{e.storage?.removeItem(ca)}catch{}this.presets=oa(e.presets);let t=ua(e.storage);this.keys=da(this.credentialStorage),this.entries=t.entries,this.presetId=this.presets.some(e=>e.id===t.preset)?t.preset:this.presets[0]?.id??``,this.active=t.active&&this.complete}get preset(){return this.presets.find(e=>e.id===this.presetId)}get baseUrl(){return this.entries[this.presetId]?.baseUrl??this.preset?.baseUrl??``}get model(){return this.entries[this.presetId]?.model??this.preset?.model??``}get key(){let e=this.keys[this.presetId];return e&&e.origin===Qi(this.baseUrl)?e.key:``}get keyForOtherAddress(){let e=this.keys[this.presetId];return!!e&&e.origin!==Qi(this.baseUrl)}get complete(){let e=Q(this.baseUrl);return!!e&&!!this.model.trim()&&(!!this.preset?.keyless||!!this.key.trim()&&Zi(e))}select(e){this.presets.some(t=>t.id===e)&&(this.presetId=e,this.resetTest(),this.save())}setBaseUrl(e){this.entries={...this.entries,[this.presetId]:{baseUrl:e,model:this.model}},this.edited()}setModel(e){this.entries={...this.entries,[this.presetId]:{baseUrl:this.baseUrl,model:e}},this.edited()}setKey(e){let t=Qi(this.baseUrl),n=e.trim();!n||!t?this.forgetKey():(this.keys={...this.keys,[this.presetId]:{origin:t,key:n}},this.edited())}forgetKey(){let{[this.presetId]:e,...t}=this.keys;this.keys=t,this.edited()}chat(){if(!this.complete)return null;let e=Q(this.baseUrl);return e?ra({baseUrl:e,model:this.model.trim(),apiKey:this.preset?.keyless?void 0:this.key,fetch:this.options.fetch}):null}async test(){let e=Q(this.baseUrl);if(!e||!this.model.trim())return this.testStatus=`failed`,this.testMessage=`Enter an http(s) address and a model first.`,{ok:!1,message:this.testMessage};if(!this.preset?.keyless&&!this.key.trim())return this.testStatus=`failed`,this.testMessage=this.keyForOtherAddress?`The saved key was entered for another address. Enter it again for this one.`:`Enter a key first.`,{ok:!1,message:this.testMessage};if(!this.preset?.keyless&&!Zi(e))return this.testStatus=`failed`,this.testMessage=`A key is only sent over https, or to this computer. Use an https address.`,{ok:!1,message:this.testMessage};this.testStatus=`testing`,this.testMessage=``;let t=await ia({baseUrl:e,model:this.model.trim(),apiKey:this.preset?.keyless?void 0:this.key,fetch:this.options.fetch});return this.testStatus=t.ok?`ok`:`failed`,this.testMessage=t.message,t}use(){return this.complete?(this.active=!0,this.save(),this.options.onChange?.(),!0):!1}stop(){this.active=!1,this.save(),this.options.onChange?.()}resetTest(){this.testStatus=`idle`,this.testMessage=``}edited(){this.resetTest();let e=this.active;e&&!this.complete&&(this.active=!1),this.save(),e&&this.options.onChange?.()}save(){try{let e=Object.fromEntries(Object.entries(this.entries).map(([e,t])=>[e,{baseUrl:Q(t.baseUrl)??``,model:t.model}])),t={preset:this.presetId,active:this.active,entries:e};this.options.storage?.setItem(sa,JSON.stringify(t)),this.credentialStorage?.setItem(ca,JSON.stringify(this.keys))}catch{}}};function pa(e,t,n,r=`local`){let i=ua(e);if(!i.active)return null;let a=oa(t).find(e=>e.id===i.preset),o=i.entries[i.preset],s=Q(o?.baseUrl??a?.baseUrl??``),c=(o?.model??a?.model??``).trim(),l=da(r===`memory`?null:e)[i.preset],u=l&&l.origin===Qi(s??``)?l.key:``;return!a||!s||!c||!a.keyless&&(!u||!Zi(s))?null:ra({baseUrl:s,model:c,apiKey:a.keyless?void 0:u,fetch:n})}var ma=`my-app`;function ha(e){return(e??``).normalize(`NFD`).replace(/\p{M}/gu,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function ga(e){return`${ha(e)||`my-app`}.cookbook.json`}function _a(e){return new TextEncoder().encode(ya(e)).length}function va(e){if(e<1e3)return`${e} bytes`;let t=e/1024;return`${t<10?t.toFixed(1):Math.round(t)} KB`}function ya(e){return`${JSON.stringify(e,null,2)}\n`}function ba(e,t){let n=URL.createObjectURL(new Blob([ya(e)],{type:`application/json`})),r=document.createElement(`a`);r.href=n,r.download=ga(t),document.body.append(r),r.click(),r.remove(),URL.revokeObjectURL(n)}var xa=`x-kitchen-token`,Sa=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function Ca(e){if(typeof e!=`string`)return!1;let t=e.trim();try{let e=t.startsWith(`/`)&&!t.startsWith(`//`),n=new URL(t,e?`https://planner.invalid`:void 0);return!e&&n.protocol!==`http:`&&n.protocol!==`https:`||n.username||n.password||n.hash?!1:![...n.searchParams.keys()].some(e=>/^(?:api[-_]?key|key|token|authorization|secret|password)$/i.test(e))}catch{return!1}}function wa(e){if(!Sa(e))return;let{endpoint:t}=e;if(Ca(t))return{endpoint:t.trim(),...Object.hasOwn(e,`token`)?{tokenInConfig:!0}:{}}}var Ta=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[];async function Ea(e,t,n=fetch){let r;try{r=await n(e.endpoint,{method:`POST`,headers:{"content-type":`application/json`,accept:`application/json`,[xa]:e.token},body:ya(t)})}catch{return{ok:!1,errors:["The kitchen could not be reached. Is `smrt kitchen` still running?"]}}let i;try{i=await r.json()}catch{i=void 0}if(r.ok&&Sa(i)&&i.ok===!0)return{ok:!0,result:{dir:typeof i.dir==`string`?i.dir:``,mode:i.mode===`update`?`update`:`new`,installed:i.installed===!0,added:Ta(i.added),nextSteps:Ta(i.nextSteps)}};let a=Sa(i)?Ta(i.errors):[];return Sa(i)&&typeof i.error==`string`&&a.push(i.error),{ok:!1,errors:a.length?a:[`The kitchen answered ${r.status}.`]}}var Da=[`manual`,`browser`,`host`,`byo`],Oa={mode:`browser`},ka={mode:`manual`},Aa=`planner.config.json`,ja=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function Ma(e){if(typeof e!=`string`)return!1;let t=e.trim();if(!t)return!1;try{let e=t.startsWith(`/`)&&!t.startsWith(`//`),n=new URL(t,e?`https://planner.invalid`:void 0);if(!e&&n.protocol!==`http:`&&n.protocol!==`https:`||n.username||n.password||n.hash)return!1;for(let e of n.searchParams.keys())if(/^(?:api[-_]?key|key|token|authorization|secret|password)$/i.test(e))return!1;return!0}catch{return!1}}function Na(e){if(!ja(e))return null;let{id:t,label:n,baseUrl:r,model:i,keyless:a,cors:o}=e;return typeof t!=`string`||!/^[a-z0-9][a-z0-9-]{0,31}$/.test(t)||typeof n!=`string`||!n.trim()||!Ma(r)||r.startsWith(`/`)?null:{id:t,label:n.trim(),baseUrl:r.trim(),...typeof i==`string`&&i.trim()?{model:i.trim()}:{},...a===!0?{keyless:!0}:{},...typeof o==`string`&&o.trim()?{cors:o.trim()}:{}}}var $=e=>({config:ka,notice:`The assistant settings could not be used (${e}), so inference is off. The planner still works manually.`});function Pa(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length===0)return null;let n=[];for(let r of e){if(typeof r!=`string`||!Da.includes(r)||r===t||n.includes(r))return null;n.push(r)}return n}function Fa(e){if(e===void 0)return{};if(!ja(e))return null;if(e.presets===void 0)return{};if(!Array.isArray(e.presets)||e.presets.length===0)return null;let t=[];for(let n of e.presets){if(typeof n==`string`&&n.trim()){t.push(n.trim());continue}let e=Na(n);if(!e)return null;t.push(e)}return{presets:t}}function Ia(e){if(!ja(e))return $(`not an object`);let t=e.inference;if(t===void 0)return{config:Oa};if(!ja(t))return $(`"inference" is not an object`);let n=t.mode;if(n===void 0)return{config:Oa};if(!Da.includes(n))return $(`unknown mode "${String(n)}"`);let r=n,i=Pa(t.alternatives,r);if(!i)return $(`alternatives must be unique supported modes other than mode`);let a=t.credentialPersistence;if(a!==void 0&&a!==`local`&&a!==`memory`)return $(`credentialPersistence must be "local" or "memory"`);let o=[r,...i],s;if(o.includes(`host`)){let e=t.host;if(!ja(e)||!Ma(e.endpoint))return $(`host mode needs host.endpoint, an http(s) URL or path`);s={endpoint:e.endpoint.trim()}}let c;return o.includes(`byo`)&&(c=Fa(t.byo)??void 0,!c)?$(`byo.presets must be a non-empty valid list`):{config:{mode:r,...i.length?{alternatives:i}:{},...a?{credentialPersistence:a}:{},...s?{host:s}:{},...c?{byo:c}:{}}}}function La(e){try{let t=JSON.parse(e),n=Ia(t),r=ja(t)?wa(t.kitchen):void 0;return r?{...n,kitchen:r}:n}catch{return $(`it is not valid JSON`)}}function Ra(e){return Ia({inference:e})}async function za(e=``,t=fetch){let n;try{n=await t(`${e.replace(/\/$/,``)}/${Aa}`,{headers:{accept:`application/json`},cache:`no-cache`})}catch{return{config:Oa}}if(n.status===404)return{config:Oa};if(!n.ok)return $(`the file answered ${n.status}`);let r=await n.text();return/^\s*</.test(r)?{config:Oa}:La(r)}var Ba=1e3,Va=2e3,Ha=6e4,Ua=(e,t)=>e.length>t?e.slice(0,t):e;function Wa(e){let t=e.fetch??fetch;return{async message(n,r){let i=(r?.history??[]).filter(e=>e.role===`user`||e.role===`assistant`).slice(-6).map(e=>({role:e.role,content:Ua(e.content,Ba)})),a={version:1,message:Ua(n,Va),snapshot:e.snapshot(),...i.length?{history:i}:{}},o=AbortSignal.timeout(Ha),s=r?.signal?AbortSignal.any([r.signal,o]):o,c=await t(e.endpoint,{method:`POST`,headers:{"content-type":`application/json`,accept:`application/json`,...e.headers?.()},body:JSON.stringify(a),signal:s});if(!c.ok)throw Error(`the server answered ${c.status}`);return await c.text()}}}function Ga(e){return[Ka(e.think),Ja(e.hear),Ya(e.speak)]}function Ka(e){let t={id:`think`,name:`Think`};if(e.mode===`manual`)return{...t,state:`off`,label:`Think: inference off`,where:`Off`};if(e.mode===`host`)return{...t,state:e.status===`ready`?`ready`:`available`,label:`Think: Server`,where:`Server`};if(e.mode===`byo`){let n=e.remote?`Your model: ${e.remote}`:``;return e.status===`ready`&&e.remote?{...t,state:`ready`,label:`Think: ${n}`,where:n}:{...t,state:`available`,label:`Think: your own model not connected`,where:`Your model`}}return{...qa(e),where:`In browser`}}function qa(e){let t={id:`think`,name:`Think`};return e.status===`unsupported`?{...t,state:`off`,label:`Think: unavailable, this browser has no WebGPU`}:e.status===`ready`?{...t,state:`ready`,label:`Think: ${e.model} ready`}:e.status===`loading`?{...t,state:`available`,label:`Think: ${e.model} loading, ${Math.round(e.progress*100)}%`}:{...t,state:`available`,label:e.downloaded?`Think: ${e.model} downloaded, not loaded`:`Think: not set up`}}function Ja(e){let t={id:`hear`,name:`Hear`};return e.mic?e.status===`browser`?{...t,state:`ready`,label:`Hear: voice typing ready, using your browser`}:e.status===`ready`?{...t,state:`ready`,label:`Hear: voice typing ready, using the downloaded model`}:e.status===`downloading`?{...t,state:`available`,label:`Hear: downloading the speech model`}:{...t,state:`available`,label:`Hear: not set up`}:{...t,state:`off`,label:`Hear: unavailable, this browser has no microphone access`}}function Ya(e){let t={id:`speak`,name:`Speak`};return e.supported?e.readAloud?{...t,state:`ready`,label:`Speak: reading replies aloud with browser voices`}:{...t,state:`available`,label:`Speak: not switched on`}:{...t,state:`off`,label:`Speak: unavailable, this browser has no speech synthesis`}}function Xa(e){return e.dismissed||e.built?!1:!(e.thinkDownloaded||e.hearDownloaded||e.readAloud)}var Za=`smrt-planner:ai:v1`;function Qa(e){let t={dismissed:!1,readAloud:!1,handsFree:!1,sendOnPause:!1};try{let n=e?.getItem(Za);if(!n)return t;let r=JSON.parse(n);t.dismissed=r.dismissed===!0,t.readAloud=r.readAloud===!0,t.handsFree=r.handsFree===!0,t.sendOnPause=r.sendOnPause===!0}catch{}return t}function $a(e,t){try{e?.setItem(Za,JSON.stringify(t))}catch{}}var eo=new class{session;voice;#e=n(i({dismissed:!1,readAloud:!1,handsFree:!1,sendOnPause:!1}));get prefs(){return e(this.#e)}set prefs(e){s(this.#e,e,!0)}#t=n(!1);get hydrated(){return e(this.#t)}set hydrated(e){s(this.#t,e,!0)}#n=n(!1);get firstRun(){return e(this.#n)}set firstRun(e){s(this.#n,e,!0)}#r=n(!1);get speaking(){return e(this.#r)}set speaking(e){s(this.#r,e,!0)}#i=n(i(Oa));get inference(){return e(this.#i)}set inference(e){s(this.#i,e,!0)}#a=n(i([`browser`]));get availableModes(){return e(this.#a)}set availableModes(e){s(this.#a,e,!0)}#o=n(``);get notice(){return e(this.#o)}set notice(e){s(this.#o,e,!0)}#s=n(null);get byo(){return e(this.#s)}set byo(e){s(this.#s,e,!0)}pending=0;generation=0;options;pendingConfig=!1;builtAtHydrate=!1;synth;mic;constructor(e){this.options=e,this.session=new Fi({...e.session,storage:e.storage,onReply:e=>this.speak(e)}),this.voice=new qi({...e.voice,storage:e.storage}),this.synth=e.synth===void 0?typeof speechSynthesis<`u`?speechSynthesis:null:e.synth,this.mic=e.mic??(typeof navigator<`u`&&!!navigator.mediaDevices)}hydrate(e){this.hydrated||(this.prefs=Qa(this.options.storage),this.hydrated=!0,this.builtAtHydrate=e,this.pendingConfig||this.decideFirstRun(),this.voice.init())}awaitConfig(){this.pendingConfig=!0}configure(e){let{config:t,notice:n}=e;this.pendingConfig=!1,this.inference=t,this.notice=n??``;let r=[t.mode,...t.alternatives??[]];this.availableModes=[...r,...t.alternatives?.length&&!r.includes(`manual`)?[`manual`]:[]],this.byo=r.includes(`byo`)?new fa({storage:this.options.storage,credentialPersistence:t.credentialPersistence,presets:t.byo?.presets,fetch:this.options.fetch,onChange:()=>this.syncByo()}):null,this.applyMode(t.mode),this.hydrated&&this.decideFirstRun()}useChat(e,t){this.pendingConfig=!1,this.inference={mode:`host`},this.notice=``,this.availableModes=[`host`],this.byo=null,this.session.setMode(`host`);let n=()=>typeof e==`function`?e():e;this.session.useRemote({message:(e,t)=>{let r=n();if(!r)throw Error(`The host has not connected a model yet.`);return r.message(e,t)}},t),this.hydrated&&this.decideFirstRun()}get assistantReady(){return this.hydrated&&this.session.status===`ready`}selectInference(e){this.availableModes.includes(e)&&e!==this.inference.mode&&(this.inference={...this.inference,mode:e},this.notice=``,this.applyMode(e))}applyMode(e){if(this.session.setMode(e),e===`host`&&this.inference.host){let{controller:e,store:t,settings:n,theme:r}=this.options.session,i=e??Zn({store:t,settings:n,theme:r});this.session.useRemote(Wa({endpoint:this.inference.host.endpoint,snapshot:()=>i.snapshot(),fetch:this.options.fetch}),`Server`)}else e===`byo`?this.syncByo():e===`manual`&&this.session.useRemote(null,``)}syncByo(){let e=this.byo;e&&this.session.useRemote(e.active?e.chat():null,e.model)}decideFirstRun(){this.firstRun=this.inference.mode!==`host`&&this.inference.mode!==`manual`&&Xa({thinkDownloaded:this.session.prefs.consented.length>0||this.session.status===`ready`,hearDownloaded:Hi(this.options.storage),readAloud:this.prefs.readAloud,dismissed:this.prefs.dismissed,built:this.builtAtHydrate})}get capabilities(){let e=ar(this.session.prefs.modelId),t=this.hydrated;return Ga({think:{status:t?this.session.status:`idle`,model:e?sr(e):`model`,progress:this.session.progress.progress,downloaded:t&&this.session.prefs.consented.length>0,mode:this.session.mode,remote:this.session.remoteLabel},hear:{status:t?this.voice.status:`checking`,mic:!t||this.mic},speak:{supported:!t||this.synth!==null,readAloud:t&&this.prefs.readAloud}})}get privacyNote(){return this.inference.mode===`manual`?`Inference is off. Planning, validation and export still work without a model.`:this.inference.mode===`host`?`Your messages and a short summary of your plan go to this site's server. Voice typing and reading aloud stay on this device.`:this.inference.mode===`byo`?`Your messages and a short summary of your plan go to the model endpoint you choose, and nowhere else. Voice typing and reading aloud stay on this device.`:`Everything runs on this device. Nothing you type or say leaves the page.`}get speakSupported(){return this.synth!==null}continueFirstRun(){this.firstRun=!1}dismissFirstRun(){this.firstRun=!1,this.setPrefs({...this.prefs,dismissed:!0})}setReadAloud(e){(!e||this.synth)&&(e||this.cancelSpeech(),this.setPrefs({...this.prefs,readAloud:e}))}setHandsFree(e){this.setPrefs({...this.prefs,handsFree:e})}setSendOnPause(e){this.setPrefs({...this.prefs,sendOnPause:e})}get sendOnPauseActive(){return this.handsFreeActive&&this.prefs.sendOnPause}get handsFreeActive(){return this.prefs.handsFree&&this.voice.status===`ready`}speak(e){if(!this.prefs.readAloud||!this.synth||!e.trim())return;this.cancelSpeech();let t=e.split(/\n{2,}/).map(e=>e.trim()).filter(Boolean),n=this.generation;this.pending=t.length,this.speaking=!0;let r=()=>{n===this.generation&&(this.pending=Math.max(0,this.pending-1),this.pending===0&&(this.speaking=!1))};for(let e of t){let t=new SpeechSynthesisUtterance(e);t.onend=r,t.onerror=r,this.synth.speak(t)}}cancelSpeech(){this.generation+=1,this.pending=0,this.speaking=!1,this.synth?.cancel()}setPrefs(e){this.prefs=e,$a(this.options.storage,e)}}({storage:v(),session:{store:ne,recipes:D,controller:nr,settings:{read:()=>C.settings(),write:e=>C.setSettings(e)},theme:{read:()=>C.snapshot().theme,write:e=>C.setTheme(e)},menu:()=>tr.openSection?nr.snapshot().sections.filter(e=>!e.hidden).map(({id:e,label:t})=>({id:e,label:t})):[]},voice:{createModel:ze}}),to=`M11 4.2C10.4 3 8.6 2.8 7.6 3.8C6.2 3.6 5 4.8 5.2 6.1C3.8 6.6 3.3 8.2 4.1 9.3C3 10.2 3 11.9 4 12.8C3.6 14.2 4.4 15.6 5.8 15.9C6.2 17.3 7.6 18.2 9 17.9C9.7 19.2 11 19.6 11 19.6ZM13 4.2 C13.6 3 15.4 2.8 16.4 3.8 C17.8 3.6 19 4.8 18.8 6.1 C20.2 6.6 20.7 8.2 19.9 9.3 C21 10.2 21 11.9 20 12.8 C20.4 14.2 19.6 15.6 18.2 15.9 C17.8 17.3 16.4 18.2 15 17.9 C14.3 19.2 13 19.6 13 19.6 ZM10.2 7.4C8.6 7.8 7.5 7 7 6.2L7.7 5.8C8.2 6.5 9 6.8 10 6.5ZM10.3 11C8.4 11.6 6.6 10.8 5.9 9.6L6.6 9.2C7.2 10.2 8.6 10.7 10.1 10.2ZM10.2 15C8.5 15.6 6.8 15 6 13.9L6.7 13.5C7.4 14.3 8.6 14.6 10 14.2ZM13.8 7.4 C15.4 7.8 16.5 7 17 6.2 L16.3 5.8 C15.8 6.5 15 6.8 14 6.5 ZM13.7 11 C15.6 11.6 17.4 10.8 18.1 9.6 L17.4 9.2 C16.8 10.2 15.4 10.7 13.9 10.2 ZM13.8 15 C15.5 15.6 17.2 15 18 13.9 L17.3 13.5 C16.6 14.3 15.4 14.6 14 14.2 Z`,no=`M17 20c-.29 0-.56-.06-.76-.15-.71-.37-1.21-.88-1.71-2.38-.51-1.56-1.47-2.29-2.39-3-.79-.61-1.61-1.24-2.32-2.53C9.29 10.98 9 9.93 9 9c0-2.8 2.2-5 5-5s5 2.2 5 5h2c0-3.93-3.07-7-7-7S7 5.07 7 9c0 1.26.38 2.65 1.07 3.9.91 1.65 1.98 2.48 2.85 3.15.81.62 1.39 1.07 1.71 2.05.6 1.82 1.37 2.84 2.73 3.55.51.23 1.07.35 1.64.35 2.21 0 4-1.79 4-4h-2c0 1.1-.9 2-2 2zM7.64 2.64L6.22 1.22C4.23 3.21 3 5.96 3 9s1.23 5.79 3.22 7.78l1.41-1.41C6.01 13.74 5 11.49 5 9s1.01-4.74 2.64-6.36zM11.5 9c0 1.38 1.12 2.5 2.5 2.5s2.5-1.12 2.5-2.5-1.12-2.5-2.5-2.5-2.5 1.12-2.5 2.5z`,ro=`M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z`;export{nr as A,ir as C,ur as D,ar as E,Bn as F,Vn as I,Dn as L,er as M,Gn as N,lr as O,Hn as P,Re as R,Rr as S,or as T,Ii as _,Wa as a,Gr as b,Ea as c,ga as d,_a as f,pa as g,ha as h,eo as i,tr as j,sr as k,ma as l,ya as m,ro as n,Ra as o,va as p,to as r,za as s,no as t,ba as u,Ri as v,cr as w,Wr as x,Ni as y,ie as z};
@@ -1 +0,0 @@
1
- import"./D31rqKs1.js";
@@ -1 +0,0 @@
1
- import"./DG3qFFTE.js";import"./xihTtKlq.js";import"./CoXf-L_3.js";import"./CdBvpdnq.js";import"./M-CuJzQN.js";import"./D2Ykv2Y3.js";import"./gMSmS-_y.js";function e(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}export{e as t};
@@ -1 +0,0 @@
1
- import{$ as e,B as t,Ct as n,Dt as r,E as i,Et as a,Ft as o,G as s,H as c,J as l,Ot as u,Pt as d,U as f,Y as p,a as m,bt as h,ct as g,d as _,ft as v,g as y,ht as b,kt as x,mt as S,n as C,nt as w,o as T,p as E,q as D,st as O,v as k,vt as A}from"./DG3qFFTE.js";import"./xihTtKlq.js";import{a as j,t as M}from"./YUSKx8_q.js";function N(e,t){u(t,!0);let n=M();d();var i=l();O(e=>c(i,e),[()=>n.t(t.key,t.vars)]),f(e,i),r()}var P=j({"ui.currency_display.invalid_code":`Invalid currency code: {code}`,"ui.currency_display.invalid_minor_unit_amount":`Invalid minor-unit amount`,"ui.currency_display.no_minor_unit":`Currency code has no minor unit: {code}`,"ui.data_table.select_all":`Select all rows`,"ui.data_table.select_current_page":`Select all rows on this page`,"ui.data_table.select_row":`Select {row}`,"ui.data_table.deselect_row":`Deselect {row}`,"ui.data_table.row_number":`row {number}`,"ui.data_table.expand":`Expand`,"ui.data_table.expand_row":`Expand {row}`,"ui.data_table.collapse_row":`Collapse {row}`,"ui.data_table.sort_ascending":`Sort {column} ascending`,"ui.data_table.sort_descending":`Sort {column} descending`,"ui.data_table.clear_sort":`Clear sorting for {column}`,"ui.data_table.loading":`Loading table data`,"ui.data_table.refreshing":`Refreshing table data`,"ui.data_table.stale":`Showing stale results`,"ui.data_table.partial_results":`Showing partial results`,"ui.data_table.load_error":`Unable to load table data`,"ui.data_table.retry":`Retry`,"ui.data_table.empty":`No data available`,"ui.data_table.virtual_region":`{caption} rows`,"ui.data_table.default_virtual_region":`Data table rows`,"ui.data_table.pagination":`Table pages`,"ui.data_table.overflow_region":`{caption} table, scroll horizontally to view more columns`,"ui.data_table.default_overflow_region":`Data table, scroll horizontally to view more columns`,"ui.data_table.more_columns":`More columns`,"ui.data_table.resize_column":`Resize {column}`,"ui.data_table.structural_row":`{kind}: {label}`,"ui.data_table.summary":`Summary`,"ui.data_table.subtotal":`Subtotal`,"ui.data_table.aggregate":`Aggregate`,"ui.data_table.footer_row":`Footer`,"ui.data_table.total":`Total`});[`input:not([type="hidden"]):not(:disabled)`,`select:not(:disabled)`,`textarea:not(:disabled)`,`button:not(:disabled)`,`a[href]`,`[tabindex]:not([tabindex="-1"]):not([type="hidden"])`,`[contenteditable="true"]`].join(`,`);function F(e){e.scrollIntoView({block:`center`,inline:`nearest`,behavior:`smooth`})}function I(e,t=1600){e.dataset.smrtHighlighted=`true`,globalThis.setTimeout(()=>{e.isConnected&&delete e.dataset.smrtHighlighted},t)}function L(e){queueMicrotask(()=>{e.isConnected&&(e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0})))})}var R=Symbol(`smrt-control-interaction`);function z(e){x(R,e)}function B(){return a(R)}function V(e,t,n){e&&t&&e.registry.recordUserEdit?.({formId:e.formId,controlId:t,subject:n})}function H(e){let t=B(),n;C(()=>{n?.(),n=void 0}),g(()=>{let r=e();if(!t||r===!1||!r.controlId){n?.(),n=void 0;return}let{controlId:i,subject:a,...o}=r,s=t.registry,c=t.formId,l=a?{type:a.type,id:a.id,label:a.label}:void 0,u=n;n=w(()=>s.register({...o,identity:{formId:c,controlId:i,subject:l}})),u?.()})}function U(e){return typeof e==`string`?[`true`,`1`,`yes`,`on`].includes(e.toLowerCase()):!!e}function W(e){if(typeof e==`boolean`)return e;if(typeof e==`object`&&e)throw Error(`staged_value_invalid`);return e}function G(e){if(e==null)return e;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return String(e);throw Error(`staged_value_invalid`)}function K(e){if(e===``||e==null)return``;if(typeof e!=`string`&&typeof e!=`number`)throw Error(`staged_value_invalid`);let t=Number(e);return Number.isFinite(t)?t:e}function q(e,t){if(typeof t!=`boolean`)return!1;let n=e.cloneNode();return n.checked=t,n.checkValidity()}function J(e,t){let n=e.cloneNode();return n.value=String(t??``),n.required&&n.value.length===0||n.minLength>=0&&n.value.length<n.minLength||n.maxLength>=0&&n.value.length>n.maxLength?!1:n.checkValidity()}function Y(e,t,n=!1){let r=String(t??``);return e.find(e=>Object.is(e.value,t))??e.find(e=>String(e.value)===r||n&&e.label===r)}function X(e,t,n){return!Array.isArray(e)||!e.every(e=>typeof e==`string`)||t!==void 0&&e.length>t?!1:n||new Set(e).size===e.length}var Z=Symbol(`smrt-form-group`);function Q(e){x(Z,e)}function $(){return a(Z)}var ee=new Set([`$$slots`,`$$events`,`$$legacy`,`checked`,`indeterminate`,`label`,`id`,`name`,`value`,`disabled`,`required`,`class`,`interaction`,`onchange`,`aria-label`,`aria-describedby`,`density`]),te=s(`<span class="smrt-checkbox__dash svelte-1o3zuy5" data-smrt-part="indicator"></span>`),ne=s(`<span class="smrt-checkbox__check svelte-1o3zuy5" data-smrt-part="indicator">✓</span>`),re=s(`<span class="smrt-checkbox__label svelte-1o3zuy5" data-smrt-part="label"> </span>`),ie=s(`<label data-smrt-hit-target="" data-smrt-component="Checkbox"><input/> <span class="smrt-checkbox__box svelte-1o3zuy5" data-smrt-part="box" aria-hidden="true"><!></span> <!></label>`);function ae(a,s){let l=D();u(s,!0);let d=m(s,`checked`,15,!1),p=m(s,`indeterminate`,3,!1),x=m(s,`disabled`,3,!1),C=m(s,`required`,3,!1),w=m(s,`class`,3,``),E=T(s,ee),j=$(),M=B(),N=h(null),P=n(()=>s.id??j?.().inputId??`smrt-checkbox-${l}`),R=n(()=>s[`aria-describedby`]??j?.().describedBy),z=n(()=>{let e=j?.().interaction;return s.interaction===!1||e===!1?!1:{...e??{},...s.interaction??{}}}),V=n(()=>e(z)===!1?void 0:e(z).id??s.name??e(P));g(()=>{e(N)&&(e(N).indeterminate=p())});function G(t){d(U(t)),e(N)&&L(e(N))}function K(e){d(e.currentTarget.checked),s.onchange?.(e)}H(()=>{let t=e(N),n=e(z);return!t||n===!1?!1:{controlId:e(V),subject:n.subject,metadata:{kind:`checkbox`,label:j?.().label??s.label??s[`aria-label`]??void 0,description:n.description??j?.().description,sensitivity:n.sensitivity??`public`,readable:n.readable,writable:n.writable,constraints:{required:C()===!0}},getValue:()=>d(),prepareValue:W,setValue:G,clear:()=>(G(!1),!0),focus:()=>t.focus(),reveal:()=>F(t),highlight:e=>I(t.closest(`label`)??t,e),validate:()=>t.reportValidity(),validateValue:e=>q(t,e),getState:()=>({disabled:t.matches(`:disabled`),readonly:!1,valid:t.validity.valid,validationMessage:t.validationMessage||void 0})}});var J=ie();let Y;var X=v(J);y(X,t=>({id:e(P),type:`checkbox`,name:s.name,value:s.value,disabled:x(),required:C(),checked:d(),"aria-label":s[`aria-label`]??(!s.label&&!j?`Checkbox`:void 0),"aria-describedby":e(R),"aria-invalid":t,onchange:K,...E,"data-smrt-part":`input`}),[()=>j?.().invalid?`true`:void 0],void 0,void 0,`svelte-1o3zuy5`,!0),_(X,e=>A(N,e),()=>e(N));var Z=b(X,2),Q=v(Z),ae=e=>{var t=te();f(e,t)},oe=e=>{var t=ne();f(e,t)};t(Q,e=>{p()?e(ae):d()&&e(oe,1)}),o(Z);var se=b(Z,2),ce=e=>{var t=re(),n=S(t,!0);O(()=>c(n,s.label)),f(e,t)};t(se,e=>{s.label&&e(ce)}),o(J),O(()=>{k(J,`data-density`,s.density),Y=i(J,1,`smrt-checkbox__root ${w()??``}`,`svelte-1o3zuy5`,Y,{"smrt-checkbox__disabled":x()}),k(J,`data-smrt-control`,e(V)),k(J,`data-smrt-form`,M?.formId),k(J,`data-smrt-subject-type`,e(z)===!1?void 0:e(z).subject?.type),k(J,`data-smrt-subject-id`,e(z)===!1?void 0:e(z).subject?.id)}),f(a,J),r()}var oe=new Set([`$$slots`,`$$events`,`$$legacy`,`id`,`type`,`value`,`placeholder`,`disabled`,`readonly`,`required`,`name`,`class`,`interaction`,`aria-label`,`aria-describedby`,`aria-invalid`,`density`]),se=s(`<input/>`);function ce(t,i){u(i,!0);let a=m(i,`type`,3,`text`),o=m(i,`value`,15,``),s=m(i,`disabled`,3,!1),c=m(i,`readonly`,3,!1),l=m(i,`required`,3,!1),d=m(i,`class`,3,``),p=T(i,oe),g=$(),v=B(),b=h(null),x=n(()=>i.id??g?.().inputId),S=n(()=>i[`aria-describedby`]??g?.().describedBy),C=n(()=>i[`aria-invalid`]??(g?.().invalid?`true`:void 0)),w=n(()=>{let e=g?.().interaction;return i.interaction===!1||e===!1?!1:{...e??{},...i.interaction??{}}}),D=n(()=>e(w)===!1?void 0:e(w).id??i.name??e(x));function O(){switch(a()){case`email`:return`email`;case`password`:return`password`;case`number`:return`number`;case`date`:return`date`;case`time`:return`time`;case`datetime-local`:return`datetime`;case`range`:return`slider`;default:return`text`}}function k(t){o(a()===`number`||a()===`range`?t===``||t==null?``:Number(t):String(t??``)),e(b)&&L(e(b))}function j(t){if(!e(b))return!0;if((a()===`number`||a()===`range`)&&t!==``&&t!=null&&!Number.isFinite(typeof t==`number`?t:Number(t)))return{valid:!1,message:`invalid_number`};let n=e(b).cloneNode(),r=String(t??``);try{n.value=r}catch{return{valid:!1,message:`invalid_value`}}return n.value===r?{valid:n.checkValidity(),message:n.validationMessage||void 0}:{valid:!1,message:`invalid_value`}}H(()=>{let t=e(b),n=e(D),r=e(w);return!t||!n||r===!1?!1:{controlId:n,subject:r.subject,metadata:{kind:O(),label:g?.().label??i[`aria-label`]??void 0,description:r.description??g?.().description,sensitivity:r.sensitivity??(a()===`password`?`secret`:`public`),readable:r.readable,writable:r.writable,constraints:{required:l()===!0,min:t.min||void 0,max:t.max||void 0,step:t.step||void 0,minLength:t.minLength>=0?t.minLength:void 0,maxLength:t.maxLength>=0?t.maxLength:void 0,pattern:t.pattern||void 0}},getValue:()=>o(),prepareValue:e=>a()===`number`||a()===`range`?K(e):G(e),setValue:k,clear:()=>(k(``),!0),focus:()=>t.focus(),reveal:()=>F(t),highlight:e=>I(t,e),validate:()=>t.reportValidity(),validateValue:j,getState:()=>({disabled:t.matches(`:disabled`),readonly:t.readOnly,valid:t.validity.valid,validationMessage:t.validationMessage||void 0})}});function M(){e(b)?.focus()}function N(){e(b)&&F(e(b))}function P(t){e(b)&&I(e(b),t)}function R(){return e(b)}var z={focus:M,reveal:N,highlight:P,getElement:R},V=se();return y(V,()=>({id:e(x),type:a(),placeholder:i.placeholder,disabled:s(),readonly:c(),required:l(),name:i.name,"aria-label":i[`aria-label`],"aria-describedby":e(S),"aria-invalid":e(C),"data-density":i.density,class:`smrt-input__root ${d()??``}`,"data-smrt-control":e(D),"data-smrt-form":v?.formId,"data-smrt-subject-type":e(w)===!1?void 0:e(w).subject?.type,"data-smrt-subject-id":e(w)===!1?void 0:e(w).subject?.id,...p,"data-smrt-component":`Input`}),void 0,void 0,void 0,`svelte-zo4qku`,!0),_(V,e=>A(b,e),()=>e(b)),E(V,o),f(t,V),r(z)}p([`keydown`,`change`]);export{I as _,U as a,N as b,G as c,X as d,H as f,L as g,B as h,$ as i,q as l,z as m,ae as n,Y as o,V as p,Q as r,W as s,ce as t,J as u,F as v,P as y};
@@ -1 +0,0 @@
1
- import{$ as e,bt as t,tt as n,vt as r}from"./DG3qFFTE.js";import{F as i,N as a,P as o,at as ee,et as s,it as c,lt as l,w as u}from"./CoXf-L_3.js";import{h as d,r as f}from"./CdBvpdnq.js";import"./GVQNHDp5.js";import{F as p,I as m,N as h,P as g,c as te}from"./DBp81N-t.js";import{a as _,i as ne,n as re,o as v,r as y,s as b}from"./C3nKLKKd.js";import{B as x,N as S,R as C,U as w,b as T,j as E,t as D,v as O,x as k}from"./B7d7dGCP.js";import{n as A}from"./Dzh-1KQR.js";import{r as j,t as M}from"./Dyf3Cj8R.js";import{a as N,c as P,d as F,l as I,n as L}from"./exPME6UK.js";function ie(e,t=h.appliedWork){return m(e.snapshot(),t)}function R(e,t,n){let r=g(e,v,n);if(r.ok){let n=t.theme,a=r.cookbook.theme,o=a?a.colorScheme||!n?.colorScheme?void 0:{...a,colorScheme:n.colorScheme}:n;t.replace(r.cookbook),o&&(t.theme=o),i(e.id),h.select(e.id,p(t.snapshot()))}return r}function z(e,t){return e.document.recipes.every(e=>t.recipes.includes(e))&&e.document.features.every(e=>t.features.includes(e))}function B(e){let t=e.recipes.flatMap(e=>{let t=k.get(e);return t?[t]:[]}),n=C(t).map(e=>{let t=new Set,n=[];for(let r of e.recipes)for(let e of O(r)){let r=x(e.packageId,e.model.name,e.key);t.has(r)||(t.add(r),n.push({id:r,href:`#`,label:e.label,icon:e.icon,description:e.description}))}return{id:`section:${e.id}`,heading:e.label,items:n}}).filter(e=>e.items.length>0),r=S(e.features).map(e=>({id:e.id,href:`#`,label:e.label,icon:e.icon,description:e.description}));return r.length&&n.push({id:`section:${E.id}`,heading:E.label,items:r}),n}function V(e){let t=e.layout;return d([],B(e),void 0,t).groups.map(e=>({id:e.id??String(e.heading),label:e.heading??``,entries:e.items.map(e=>({id:e.id??e.href,label:t?.items?.[e.id??e.href]?.label?.trim()||e.label}))}))}var H={live:`Live`,mock:`Mock`,sample:`Sample`,server:`Server`},U={live:`Runs for real in your browser.`,mock:`Runs in your browser, but a provider is faked.`,sample:`Shows sample data only; it cannot reach what it needs.`,server:`Needs a server, which this browser-only demo does not have.`},W={live:`success`,mock:`info`,sample:`warning`,server:`default`};function G(e){return e.effectiveDemo??e.demo}function K(e){if(e)return{mode:e.mode,label:H[e.mode],meaning:U[e.mode],variant:W[e.mode],reasons:e.reasons,mocked:e.mocked??[]}}function q(e){if(!e)return;if(e.status===`browser-safe`)return`Its package builds for a browser.`;let t=[`Its package does not build for a browser yet`];return e.reason&&t.push(`(${e.reason})`),e.issues?.length&&t.push(`and is tracked in ${e.issues.join(`, `)}`),`${t.join(` `)}.`}var J=`@happyvertical/smrt-commerce:`,Y=`${J}TaxCode`,ae=`${J}TaxComponent`,X=`${J}TaxSettings`,oe=`${J}DocumentTax`;function Z(){let e=o()??.05;return{codes:c(e),fallback:s(e)}}function se(e){try{let t=e?.getItem(ne);if(!t)return;let n=b(t,{dropUnknownRecipes:!0});n.ok&&y(n.cookbook)}catch{}}function ce(){return se(_()),M({storage:_(),defaults:e=>D.apply(e).background,empty:[N,L,oe],samples:{[Y]:{from:[],make:()=>Z().codes.map(e=>({id:e.id,code:e.code,name:e.name,kind:e.kind,appliesTo:e.appliesTo,active:e.active,componentsJson:JSON.stringify(e.components.map(e=>({taxComponentId:e.id,compound:!1})))}))},[ae]:{from:[],make:()=>ee(Z().codes).map(e=>({id:e.id,name:e.name,percent:e.percent,liabilityAccountId:null,recoverable:e.recoverable,active:!0}))},[X]:{from:[],make:()=>{let{fallback:e}=Z(),t=a();return[{id:u(`${X}:sample`),defaultSalesTaxCodeId:e.id,defaultPurchaseTaxCodeId:e.id,defaultLineAmountType:t.pricesIncludeTax?`inclusive`:`exclusive`,taxRoundingScope:t.taxRounding}]}},...P(j),[I]:{from:[j(`@happyvertical/smrt-products:Product`)],make:([e])=>(e??[]).map((e,t)=>({id:u(`${I}:sample:${e.id}`),name:`${String(e.name??`Product`)} image`,sourceUri:`data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 240"><rect width="240" height="240" fill="hsl(${t*47%360} 40% 82%)"/><circle cx="120" cy="94" r="46" fill="hsl(${(t*47+30)%360} 35% 58%)"/><path d="M44 214c20-55 132-55 152 0" fill="hsl(${(t*47+10)%360} 30% 46%)"/><text x="120" y="224" text-anchor="middle" font-family="sans-serif" font-size="14" fill="white">${String(e.name??``).replace(/[<&>]/g,``)}</text></svg>`)}`,mimeType:`image/svg+xml`,description:`Sample image for ${String(e.name??`this product`)}.`,sourceType:`browser-demo`}))},[F]:{from:[j(`@happyvertical/smrt-products:Product`),j(I)],make:([e,t])=>(e??[]).flatMap((e,n)=>{let r=t?.[n];return r?[{id:u(`${F}:sample:${e.id}`),productId:e.id,assetId:r.id,relationship:`gallery`,sortOrder:0}]:[]})}},children:{models:l.packages.flatMap(e=>e.models),links:e=>w(l,T,e)}})}var le=new class{#e=t(void 0);get endpoint(){return e(this.#e)}set endpoint(e){r(this.#e,e,!0)}#t=t(!1);get tokenInConfig(){return e(this.#t)}set tokenInConfig(e){r(this.#t,e,!0)}#n=t(void 0);get token(){return e(this.#n)}set token(e){r(this.#n,e,!0)}#r=t(`idle`);get status(){return e(this.#r)}set status(e){r(this.#r,e,!0)}#i=t(void 0);get outcome(){return e(this.#i)}set outcome(e){r(this.#i,e,!0)}get config(){return this.endpoint&&this.token&&!this.tokenInConfig?{endpoint:this.endpoint,token:this.token}:void 0}get needsLink(){return!!this.endpoint&&!this.token&&!this.tokenInConfig}configure(e,t){this.endpoint=e?.endpoint,this.tokenInConfig=e?.tokenInConfig===!0,this.token=e?t:void 0,this.status=`idle`,this.outcome=void 0}async send(e,t){let n=this.config;if(!n||this.status===`sending`)return;this.status=`sending`,this.outcome=void 0;let r=await te(n,e,t);this.outcome=r,this.status=r.ok?`sent`:`failed`}},Q=`cookbook`,$=new class{#e=t(null);get open(){return e(this.#e)}set open(e){r(this.#e,e,!0)}#t=t(null);get returnTo(){return e(this.#t)}set returnTo(e){r(this.#t,e,!0)}navigator=null;show(e){this.returnTo=e,this.navigator?this.navigator.open(e):this.set(e)}back(){this.open&&(this.returnTo=this.open),this.navigator?this.navigator.close():this.set(null)}async set(e,t=!0){this.open!==e&&(t?await f(async()=>{this.open=e,await n()}):this.open=e)}};function ue(e,t){let n=new URLSearchParams(e).get(Q);return n&&t.includes(n)?n:null}function de(e,t){let n=new URLSearchParams(e);t?n.set(Q,t):n.delete(Q);let r=n.toString().replace(/%2C/gi,`,`);return r?`?${r}`:``}var fe=`Planner`;function pe(e,t,n=A,r=fe){let i=e.name?.trim();if(i)return i;let a=t?n.find(e=>e.id===t):void 0;return a&&z(a,e)?a.name:r}function me(e){return pe(re.snapshot(),h.active,void 0,e)}export{le as a,K as c,V as d,R as f,de as i,G as l,ie as m,ue as n,ce as o,z as p,$ as r,q as s,me as t,B as u};