@kashi-ui/elements 2.24.1 → 2.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/README.md +3 -3
  2. package/dist/base.d.ts +110 -0
  3. package/dist/capture.d.ts +75 -0
  4. package/dist/capture.js +456 -0
  5. package/dist/cdn/{appointment-DOXBUwIU.js → appointment-BaEWfjSX.js} +1 -1
  6. package/dist/cdn/base-BqFAMlwG.js +1 -0
  7. package/dist/cdn/{basic-DuY4RslZ.js → basic-BBvsRt91.js} +1 -1
  8. package/dist/cdn/{buttons-BaK6bx3w.js → buttons-BmP5wikN.js} +1 -1
  9. package/dist/cdn/{calendar-BulPeVAJ.js → calendar-CwKogl-G.js} +1 -1
  10. package/dist/cdn/capture-B48H5hmR.js +24 -0
  11. package/dist/cdn/{card-BKiwJF34.js → card-C0nariT-.js} +1 -1
  12. package/dist/cdn/{cards-DKarXHsC.js → cards-D9-wNDK8.js} +1 -1
  13. package/dist/cdn/{charts-ETYOAJyB.js → charts-Cct32znI.js} +1 -1
  14. package/dist/cdn/{chat-D5ZIMnNp.js → chat-Dg5CEN6Y.js} +1 -1
  15. package/dist/cdn/{choice-DBvC2Puo.js → choice-cDqbHUTC.js} +1 -1
  16. package/dist/cdn/combobox-Drm8K9Zk.js +1 -0
  17. package/dist/cdn/commerce-JkDctt2h.js +1 -0
  18. package/dist/cdn/{content-DN3eXLg-.js → content-CqUXcDCi.js} +1 -1
  19. package/dist/cdn/{controls--OMZkJYe.js → controls-CquzGwtr.js} +1 -1
  20. package/dist/cdn/{display-BfYWAjNu.js → display-DW5JEQXT.js} +1 -1
  21. package/dist/cdn/{fields-B-jTUQiI.js → fields-C-ytjZil.js} +1 -1
  22. package/dist/cdn/forms-CurTYl2V.js +1 -0
  23. package/dist/cdn/gantt-QfHFG7O8.js +14 -0
  24. package/dist/cdn/{holidays-Cu6IfbTL.js → holidays-DgmHlqJX.js} +1 -1
  25. package/dist/cdn/{hours-CeiVqPKD.js → hours-CmICISQO.js} +1 -1
  26. package/dist/cdn/inputs-DWLKbi57.js +1 -0
  27. package/dist/cdn/invoice-BUMyjBVi.js +10 -0
  28. package/dist/cdn/kashi-elements.js +1 -1
  29. package/dist/cdn/{legal-id-Mt8FX0fV.js → legal-id-B_0kbcQT.js} +1 -1
  30. package/dist/cdn/lists-D0dao20N.js +1 -0
  31. package/dist/cdn/{map-TfSt3CjL.js → map-BxlzfCbM.js} +1 -1
  32. package/dist/cdn/{media-BRBINvzU.js → media-QVgCYQSu.js} +1 -1
  33. package/dist/cdn/{menu-DTNVFXrb.js → menu-DcFyTTHv.js} +1 -1
  34. package/dist/cdn/{money-CjGI2VIQ.js → money-BFEbgLJn.js} +1 -1
  35. package/dist/cdn/{nav-CT5RVOzy.js → nav-Cm8mAT09.js} +1 -1
  36. package/dist/cdn/{overlay-CS8piW6X.js → overlay-C1nbLv6h.js} +1 -1
  37. package/dist/cdn/pickers-DQgK1WAX.js +1 -0
  38. package/dist/cdn/{relative-OC1fV3Xh.js → relative-BoBZPiB7.js} +1 -1
  39. package/dist/cdn/{rich-text-CS6xEim6.js → rich-text-9IAZ_T8A.js} +1 -1
  40. package/dist/cdn/search-BvShDz2X.js +1 -0
  41. package/dist/cdn/{sheets-CVbD98PY.js → sheets-CNF5lSVn.js} +1 -1
  42. package/dist/cdn/table-D1xiHZCM.js +2 -0
  43. package/dist/cdn/{text-C6fzEBBh.js → text-DFyW6cuq.js} +1 -1
  44. package/dist/cdn/{time-CkqqUKJv.js → time-CYZzyy_3.js} +1 -1
  45. package/dist/cdn/{time-CwOYrtK-.js → time-oyKIQ2bk.js} +1 -1
  46. package/dist/cdn/{validate-Dr2f6i6s.js → validate-CRU7rfNs.js} +1 -1
  47. package/dist/cdn/{work-DoNAKgVU.js → work-DS2MbtGM.js} +1 -1
  48. package/dist/cdn.js +5 -1
  49. package/dist/combobox.js +4 -4
  50. package/dist/commerce.js +2 -2
  51. package/dist/gantt.d.ts +41 -0
  52. package/dist/gantt.js +179 -0
  53. package/dist/index.d.ts +18 -3
  54. package/dist/index.js +8 -3
  55. package/dist/inputs.d.ts +16 -0
  56. package/dist/inputs.js +62 -2
  57. package/dist/invoice.d.ts +52 -0
  58. package/dist/invoice.js +75 -0
  59. package/dist/lists.d.ts +57 -0
  60. package/dist/lists.js +306 -0
  61. package/dist/manifest.json +168 -3
  62. package/dist/pickers.d.ts +4 -0
  63. package/dist/pickers.js +34 -6
  64. package/dist/table.d.ts +15 -1
  65. package/dist/table.js +184 -5
  66. package/package.json +4 -4
  67. package/dist/cdn/base-D4tCOysh.js +0 -1
  68. package/dist/cdn/combobox-BGuPAAt3.js +0 -1
  69. package/dist/cdn/commerce-SzWdpWJG.js +0 -1
  70. package/dist/cdn/forms-DgRiYmdV.js +0 -1
  71. package/dist/cdn/inputs-BkJ70Xkc.js +0 -1
  72. package/dist/cdn/pickers-BwDRsDRo.js +0 -1
  73. package/dist/cdn/table-tgB4iwcM.js +0 -1
@@ -0,0 +1 @@
1
+ import{n as e}from"./text-DFyW6cuq.js";import{n as t}from"./search-BvShDz2X.js";import{_ as n,c as r,l as i,m as a,o,p as s,r as c,t as l,u,v as d,y as f}from"./base-BqFAMlwG.js";var p=Object.defineProperty,m=(e,t)=>{let n=Object.setPrototypeOf({},null);for(var r in e)p(n,r,{get:e[r],enumerable:!0});return t&1||p(n,Symbol.toStringTag,{value:`Module`}),t&2?n:Object.preventExtensions(n)};const h=[{name:`آذربایجان شرقی`,capital:`تبریز`,areaCode:`41`},{name:`آذربایجان غربی`,capital:`ارومیه`,areaCode:`44`},{name:`اردبیل`,capital:`اردبیل`,areaCode:`45`},{name:`اصفهان`,capital:`اصفهان`,areaCode:`31`},{name:`البرز`,capital:`کرج`,areaCode:`26`},{name:`ایلام`,capital:`ایلام`,areaCode:`84`},{name:`بوشهر`,capital:`بوشهر`,areaCode:`77`},{name:`تهران`,capital:`تهران`,areaCode:`21`},{name:`چهارمحال و بختیاری`,capital:`شهرکرد`,areaCode:`38`},{name:`خراسان جنوبی`,capital:`بیرجند`,areaCode:`56`},{name:`خراسان رضوی`,capital:`مشهد`,areaCode:`51`},{name:`خراسان شمالی`,capital:`بجنورد`,areaCode:`58`},{name:`خوزستان`,capital:`اهواز`,areaCode:`61`},{name:`زنجان`,capital:`زنجان`,areaCode:`24`},{name:`سمنان`,capital:`سمنان`,areaCode:`23`},{name:`سیستان و بلوچستان`,capital:`زاهدان`,areaCode:`54`},{name:`فارس`,capital:`شیراز`,areaCode:`71`},{name:`قزوین`,capital:`قزوین`,areaCode:`28`},{name:`قم`,capital:`قم`,areaCode:`25`},{name:`کردستان`,capital:`سنندج`,areaCode:`87`},{name:`کرمان`,capital:`کرمان`,areaCode:`34`},{name:`کرمانشاه`,capital:`کرمانشاه`,areaCode:`83`},{name:`کهگیلویه و بویراحمد`,capital:`یاسوج`,areaCode:`74`},{name:`گلستان`,capital:`گرگان`,areaCode:`17`},{name:`گیلان`,capital:`رشت`,areaCode:`13`},{name:`لرستان`,capital:`خرم‌آباد`,areaCode:`66`},{name:`مازندران`,capital:`ساری`,areaCode:`11`},{name:`مرکزی`,capital:`اراک`,areaCode:`86`},{name:`هرمزگان`,capital:`بندرعباس`,areaCode:`76`},{name:`همدان`,capital:`همدان`,areaCode:`81`},{name:`یزد`,capital:`یزد`,areaCode:`35`}],g={"آذربایجان شرقی":/* @__PURE__ */ `آبشاحمد.آچاچی.آذرشهر.آقکند.اسکو.اهر.ایلخچی.باسمنج.بخشایش.بستان‌آباد.بناب.بناب مرند.تبریز.ترک.ترکمانچای.تسوج.تیکمهداش.تیمورلو.جلفا.جوانقلعه.خاروانا.خامنه.خداجو.خسروشاه.خمارلو.خواجه.دریان.دوزدوزان.زرنق.زنوز.سراب.سردرود.سهند.سیس.سیهرود.شبستر.شربیان.شرفخانه.شندآباد.شهریار.صوفیان.عجبشیر.قرهآغاج.کشکسرای.کلوانق.کلیبر.کوزهکنان.گوگان.لیلان.مبارک آباد.مراغه.مرند.ملکان.ملککیان.ممقان.مهربان.میانه.نظرکهریزی.وایقان.ورزقان.هادی‌شهر.هریس.هشترود.هوراند.یامچی`.split(`.`),"آذربایجان غربی":/* @__PURE__ */ `آواجیق.ارومیه.اشنویه.ایواوغلی.باروق.بازرگان.بوکان.پلدشت.پیرانشهر.تازه‌شهر.تکاب.چهاربرج.خلیفان.خوی.دیزج دیز.ربط.زرآباد.سردشت.سرو.سلماس.سیلوانه.سیمینه.سیهچشمه.شاهیندژ.شوط.فیرورق.قرهضیاءالدین.قطور.قوشچی.کشاورز.گردکشانه.ماکو.محمدیار.محمودآباد.مرگنلر.مهاباد.میاندوآب.میرآباد.نازک علیا.نالوس.نقده.نوشینشهر`.split(`.`),اردبیل:[`آبیبیگلو`,`اردبیل`,`اسلام‌آباد قدیم`,`اصلاندوز`,`انگوت`,`بیلهسوار`,`پارس‌آباد`,`جعفرآباد`,`خلخال`,`رضی`,`سرعین`,`عنبران`,`قصابه`,`کلور`,`کوراییم`,`گرمی`,`گیوی`,`لاهرود`,`مرادلو`,`مشگینشهر`,`نمین`,`نیر`,`هشجین`,`هیر`],اصفهان:/* @__PURE__ */ `آران و بیدگل.ابریشم.ابوزیدآباد.اردستان.اژیه.اشترجان.اصغرآباد.اصفهان.افوس.انارک.بادرود.باغ بهادران.باغشاد.بافران.برزک.برفانبار.بوئین و میاندشت.بهارانشهر.بهارستان.پیربکران.تودشک.تیران.جندق.جوزدان.جوشقان قالی.جوشقان و کامو.چادگان.چرمهین.چمگردان.حبیب آباد برخوار.حسن‌آباد.حنا.خالدآباد.خمینی‌شهر.خوانسار.خور.خوراسگان.خورزوق.داران.دامنه.درچهپیاز.دستگرد.دولت‌آباد.دهاقان.دهق.دیزیچه.رزوه.رضوانشهر.زازران.زایندهرود.زرینشهر.زواره.زیار.زیباشهر.سده لنجان.سفیدشهر.سگزی.سمیرم.سین.شاپورآباد.شاهینشهر.شهر جدید مجلسی.شهرضا.طالخونچه.طرق.عسگران.علویجه.فرخی.فریدونشهر.فلاورجان.فولادشهر.قمصر.قهجاورستان.قهدریجان.کاشان.کرکوند.کلیشاد و سودرجان.کمشجه.کمه.کوشک.کوهپایه.کهریزسنگ.گرگاب.گز.گلپایگان.گلدشت.گلشن.گلشهر.گوگد.لای بید.مبارکه.محمدآباد.مشکات.منظریه.مهاباد.میمه.نائین.نجف‌آباد.نصرآباد.نطنز.نوش‌آباد.نیاسر.نیک‌آباد.ورزنه.ورنامخواست.وزوان.ونک.هرند.یزدانشهر نجف آباد`.split(`.`),البرز:[`آسارا`,`اشتهارد`,`تنکمان`,`چهارباغ`,`طالقان`,`فردیس`,`کرج`,`کمالشهر`,`کوهسار`,`گرمدره`,`گلسار`,`ماهدشت`,`محمدشهر`,`مشکیندشت`,`مهستان`,`نظرآباد`],ایلام:/* @__PURE__ */ `آبدانان.آسمان‌آباد.ارکواز.ایلام.ایوان.بدره.بلاوه تره سفلی.پهله.توحید.جعفرآباد.چشمه شیرین.چوار.دره‌شهر.دلگشا.دهلران.زرنه.سرابباغ.سرابله.شباب.صالح‌آباد.لومار.ماژین.مورموری.موسیان.مهر.مهران.میمه`.split(`.`),بوشهر:/* @__PURE__ */ `آباد.آبپخش.آبدان.امام حسن.انارستان.اهرم.بادوله.برازجان.بردخون.بردستان.بندر دیر.بندر دیلم.بندر ریگ.بندر سیراف.بندر کنگان.بندر گناوه.بندو.بنک.بوشکان.بوشهر.تنگ ارم.جم.چغادک.خارگ.خورموج.دالکی.دلوار.دوراهک.ریز.سعدآباد.شبانکاره.شنبه.عالی‌شهر.عسلویه.کاکی.کلمه.نخل تقی.وحدتیه`.split(`.`),تهران:/* @__PURE__ */ `آبسرد.آبعلی.احمدآباد مستوفی.ارجمند.اسلامشهر.اندیشه.باغستان.باقرشهر.بومهن.پاکدشت.پردیس.پرند.پیشوا.تهران.جلیل‌آباد.جوادآباد.چهاردانگه.حسن‌آباد.خاورشهر.دماوند.رباطکریم.رودهن.شاهدشهر.شریف‌آباد.شمشک.شهر ری.شهریار.صالحیه.صباشهر.صفادشت.فردوسیه.فرون‌آباد.فشم.فیروزکوه.قدس.قرچک.کرشته.کهریزک.کیلان.گلستان.لواسان.ملارد.نسیم‌شهر.نصیرشهر.وحیدیه.ورامین`.split(`.`),"چهارمحال و بختیاری":/* @__PURE__ */ `آلونی.اردل.باباحیدر.بروجن.بلداجی.بن.پردنجان.تلورد.جونقان.چالشتر.چلگرد.چلیچه.دستنا.دشتک.سامان.سرخون.سردشت.سفیددشت.سودجان.سورشجان.شلمزار.شهرکرد.صمصامی.طاقانک.فارسان.فرادنبه.فرخشهر.کاج.کیان.گندمان.گوجان.گهرو.لردگان.مالخلیفه.منج نسا.ناغان.نافچ.وردنجان.هارونی.هرچگان.هفشجان.یانچشمه`.split(`.`),"خراسان جنوبی":/* @__PURE__ */ `آرینشهر.آیسک.ارسک.اسدیه.اسفدن.اسلامیه.باغستان علیا.بشرویه.بیرجند.حاجی‌آباد.خضری دشتبیاض.خوسف.درح.دیهوک.زهان.سرایان.سربیشه.سهقلعه.شوسف.طبس.طبس مسینا.عشق‌آباد.فردوس.قائن.قهستان.گزیک.محمدشهر.مود.نهبندان.نیمبلوک`.split(`.`),"خراسان رضوی":/* @__PURE__ */ `احمدآباد.انابد.باجگیران.باخرز.بار.بایگ.بجستان.بردسکن.بیدخت.بینالود.تایباد.تربت جام.تربت حیدریه.جغتای.جنگل.چاپشلو.چکنه.چناران.خرو.خلیل‌آباد.خواف.داورزن.دررود.درگز.دولت‌آباد.رادکان.رباط سنگ.رشتخوار.رضویه.رودآب.ریوش.سبزوار.سرخس.سفیدسنگ.سلامی.سلطان‌آباد.سنگان.سیدآباد.شادمهر.شاندیز.ششتمد.شهرآباد.شهرزو.شهرکهنه.صالح‌آباد.طرقبه.عشق‌آباد.فرگ قلعه.فرهادگرد.فریمان.فیروزه.فیض‌آباد.قاسم‌آباد.قدمگاه.قلندرآباد.قوچان.کاخک.کاریز.کاشمر.کدکن.کلات.کندر.گلبهار.گلمکان.گناباد.لطف‌آباد.مزداوند.مشهد.مشهد ریزه.ملک‌آباد.نسر.نشتیفان.نصرآباد.نقاب.نوخندان.نیشابور.نیلشهر.همت‌آباد.یونسی`.split(`.`),"خراسان شمالی":[`آشخانه`,`آوا`,`اسفراین`,`ایور`,`بجنورد`,`پیشقلعه`,`تیتکانلو`,`جاجرم`,`چنارانشهر`,`حصار گرمخان`,`درق`,`راز`,`زیارت`,`سنخواست`,`شوقان`,`شیروان`,`صفی‌آباد`,`فاروج`,`فیروزه`,`قاضی`,`گرمه`,`لوجلی`],خوزستان:/* @__PURE__ */ `آبادان.آبژدان.آغاجاری.ابوحمیظه.اروندکنار.الوان.الهایی.امیدیه.اندیمشک.اهواز.ایذه.باغملک.بستان.بندر امام خمینی.بندر ماهشهر.بهبهان.بیدروبهمرکزی.ترکالکی.تشان.جایزان.جنتمکان.چغامیش.چم گلک.چمران.چویبده.حر ریاحی.حسینیه.حمیدیه.خرمشهر.دارخوین.دزآب.دزفول.دهدز.رامشیر.رامهرمز.رفیع.زهره.سالند.سردشت.سماله.سوسنگرد.سیاهمنصور.شادگان.شمس‌آباد.شوش.شوشتر.شهرک حمزه.شیبان.صالح شهر.صفی‌آباد.صیدون.فتح‌المبین.قلعه خواجه.قلعهتل.کوت سیدنعیم طالقانی.کوت عبدالله.گتوند.گوریه.لالی.مسجدسلیمان.مشراگه.مقاومت.ملاثانی.منصوریه.میانرود.میانکوه.میداود.مینوشهر.ویس.هفتکل.هندیجان.هویزه`.split(`.`),زنجان:[`آببر`,`ابهر`,`ارمغانخانه`,`چورزق`,`حلب`,`خرمدره`,`دندی`,`زرین‌آباد`,`زرینرود`,`زنجان`,`سجاس`,`سلطانیه`,`سهرورد`,`صایینقلعه`,`قیدار`,`کرسف`,`گرماب`,`ماهنشان`,`نیکپی`,`هیدج`],سمنان:[`آرادان`,`امیریه`,`ایوانکی`,`بسطام`,`بیارجمند`,`دامغان`,`درجزین`,`دیباج`,`رودیان`,`سرخه`,`سمنان`,`شاهرود`,`شهمیرزاد`,`کلاته خیج`,`کلاته رودبار`,`کهن‌آباد`,`گرمسار`,`مجن`,`مهدی‌شهر`,`میامی`],"سیستان و بلوچستان":/* @__PURE__ */ `آسپیچ محمدی.ادیمی.اسپکه.ایرانشهر.بریس.بزمان.بمپور.بنت.بنجار.پیشین.جالق.چابهار.خاش.دوستمحمد.راسک.رامشار.زابل.زاهدان.زرآباد.زهک.سراوان.سرباز.سوران.سیب.سیرکان.شهرک علیاکبر.فنوج.قصرقند.کنارک.گشت.گلمورتی.محمدآباد.مهرستان.میرجاوه.نصرت‌آباد.نگور.نوک‌آباد.نیکشهر.هیدوچ`.split(`.`),فارس:/* @__PURE__ */ `آباده.آباده طشک.ارد.اردکان.ارسنجان.استهبان.اسیر.اشکنان.افزر.اقلید.اوز.اهل.ایج.ایزدخواست.باب انار.بابامنیر.بایگان.بنارویه.بوانات.بهمن.بیرم.بیضا.جنتشهر.جویم.جهرم.حاجی‌آباد.حسامی.حسن‌آباد.خانه زنیان.خانیمن.خاوران.خرامه.خشت.خنج.خور.خوزی.خومهزار.داراب.داریان.دبیران.دژکرد.دوبرجی.دوزه.دهرم.رامجرد.رونیز.زاهدشهر.زرقان.سده.سروستان.سعادتشهر.سلطانشهر.سورمق.سیدان.ششده.شهر جدید صدرا.شهرپیر.شهرک امام.شیراز.صغاد.صفاشهر.علامرودشت.عمادشهر.فاروق.فتح آباد.فدامی.فراشبند.فسا.فیروزآباد.فیشور.قائمیه.قادرآباد.قرهبلاغ.قطب‌آباد.قطرویه.قیر.کازرون.کامفیروز.کرهای.کنارتخته.کوار.کوپن.کوهنجان.گراش.گلهدار.گویم.لار.لامرد.لپوئی.لطیفی.مادرسلیمان.مرودشت.مزایجان.مشکان.مصیری.مهر.میانشهر.میمند.نوبندگان.نوجین.نودان.نورآباد.نیریز.والاشهر.وراوی.هماشهر`.split(`.`),قزوین:[`آبگرم`,`آبیک`,`آوج`,`ارداق`,`اسفرورین`,`اقبالیه`,`الوند`,`بوئینزهرا`,`بیدستان`,`تاکستان`,`خاکعلی`,`خرمدشت`,`دانسفهان`,`رازمیان`,`سگزآباد`,`سیردان`,`شال`,`ضیاءآباد`,`قزوین`,`کوهین`,`محمدیه`,`محمودآباد نمونه`,`معلمکلایه`,`نرجه`],قم:[`جعفریه`,`دستجرد`,`سلفچگان`,`قاهان`,`قم`,`قنوات`,`کهک`],کردستان:/* @__PURE__ */ `آرمرده.اورامان.بابارشانی.بانه.برده رشه.بلبان‌آباد.بویین سفلی.بیجار.پیرتاج.توپآغاج.چناره.حسن‌آباد یاسوکند.دزج.دلبران.دهگلان.دیواندره.زرینه.سروآباد.سریش‌آباد.سقز.سنندج.شویشه.صاحب.قروه.کامیاران.کانیدینار.کانیسور.مریوان.موچش`.split(`.`),کرمان:/* @__PURE__ */ `اختیارآباد.ارزوئیه.امینشهر.انار.اندوهجرد.باغین.بافت.بردسیر.بروات.بزنجان.بلورد.بلوک.بم.بهرمان.پاریز.جبالبارز.جوپار.جوزم.جیرفت.چترود.خاتون‌آباد.خانوک.خرسند.خواجو شهر.درب بهشت.دشتکار.دوساری.دهج.دهستان بزنجان.رابر.راور.راین.رفسنجان.ریحانشهر.زرند.زنگی‌آباد.زهکلوت.زیدآباد.سیرجان.سیریز.شهداد.شهربابک.صفائیه.عنبرآباد.فاریاب.فهرج.قلعهگنج.کاظم‌آباد.کرمان.کشکوئیه.کوهبنان.کهنوج.کیانشهر.گلباف.گلزار.لاله زار.ماهان.محمدآباد.محمدآباد گنبکی.محی‌آباد.مردهک.مس سرچشمه.منوجان.نجفشهر.نرماشیر.نظامشهر.نگار.نودژ.هجدک.هماشهر.هنزا.یزدانشهر`.split(`.`),کرمانشاه:/* @__PURE__ */ `ازگله.اسلام‌آباد غرب.بانهوره.باینگان.بیستون.پاوه.تازه‌آباد.جوانرود.حمیل.روانسر.ریژاو.سرپل ذهاب.سرمست.سطر.سنقر.سومار.شروینه.صحنه.قصر شیرین.قلعه.کرمانشاه.کرند غرب.کنگاور.کوزران.گودین.گهواره.گیلانغرب.ماهیدشت.میانراهان.نودشه.نوسود.هرسین.هلشی`.split(`.`),"کهگیلویه و بویراحمد":[`باشت`,`پاتاوه`,`چرام`,`چیتاب`,`دوگنبدان`,`دهدشت`,`دیشموک`,`سوق`,`سیسخت`,`قلعه رئیسی`,`گراب سفلی`,`لنده`,`لیکک`,`مادوان علیا`,`مارگون`,`محله چینیها`,`یاسوج`],گلستان:/* @__PURE__ */ `آزادشهر.آققلا.انبارآلوم.اینچهبرون.بندر ترکمن.بندر گز.تاتار علیا.خانببین.دلند.رامیان.سرخنکلاته.سنگدوین.سیمینشهر.علی‌آباد کتول.فاضل‌آباد.فراغی.قرق.کردکوی.کلاله.گالیکش.گرگان.گمیشان.گنبد کاووس.مراوهتپه.مزرعه.مینودشت.نگینشهر.نوده خاندوز.نوکنده`.split(`.`),گیلان:/* @__PURE__ */ `آستارا.آستانه اشرفیه.احمدسرگوراب.اسالم.اطاقور.املش.بازارجمعه.برهسر.بندر انزلی.بندر کیاشهر.پرهسر.توتکابن.جیرنده.چابکسر.چاف و چمخاله.چوبر.حویق.خشکبیجار.خمام.دیلمان.رانکوه.رحیم‌آباد.رستم‌آباد.رشت.رضوانشهر.رودبار.رودبنه.رودسر.سنگر.سیاهکل.شفت.شلمان.صومعهسرا.فومن.کلاچای.کوچصفهان.کومله.گوراب زرمیخ.لاهیجان.لشت نشا.لنگرود.لوشان.لولمان.لوندویل.لیسار.ماسال.ماسوله.ماکلوان.مرجغل.منجیل.واجارگاه.هشتپر`.split(`.`),لرستان:[`ازنا`,`اشترینان`,`الشتر`,`الیگودرز`,`بروجرد`,`بیرانشهر`,`پل دختر`,`چالانچولان`,`چقابل`,`خرم‌آباد`,`درب گنبد`,`دورود`,`زاغه`,`سپیددشت`,`سرابدوره`,`شول‌آباد`,`فیروزآباد`,`کونانی`,`کوهدشت`,`گراب لکستان`,`معمولان`,`مومن‌آباد`,`نورآباد`,`ویسیان`,`هفتچشمه`],مازندران:/* @__PURE__ */ `آلاشت.آمل.ارطه.اکند.امامزاده عبدالله.امیرکلا.ایزدشهر.بابل.بابلسر.بلده.بهشهر.بهنمیر.پایین هولار.پل سفید.پول.تنکابن.جویبار.چالوس.چمستان.خرم‌آباد.خلیلشهر.خوشرودپی.دابودشت.رامسر.رستمکلا.رویان.رینه.زرگرمحله.زیرآب.ساری.سرخرود.سلمانشهر.سورک.شیرگاه.شیرود.طبقده.عباس‌آباد.فرح‌آباد.فریدونکنار.فریم.قائمشهر.کتالم و ساداتشهر.کجور.کلارآباد.کلاردشت.کلهبست.کوهیخیل.کیاسر.کیاکلا.گتاب.گزنک.گلوگاه.محمودآباد.مرزن‌آباد.مرزیکلا.نشتارود.نکا.نمکآبرود.نور.نوشهر.هچیرود`.split(`.`),مرکزی:/* @__PURE__ */ `آستانه.آشتیان.آوه.اراک.پرندک.تفرش.توره.جاورسیان.خشکرود.خمین.خنجین.خنداب.داوودآباد.دلیجان.رازقان.زاویه.ساروق.ساوه.سنجان.شازند.شهباز.شهر جدید امیرکبیر.غرق‌آباد.فرمهین.قورچیباشی.کارچان.کرهرود.کمیجان.مأمونیه.محلات.مهاجران.میلاجرد.نراق.نوبران.نیمور.هندودر`.split(`.`),هرمزگان:/* @__PURE__ */ `ابوموسی.بستک.بندر چارک.بندر خمیر.بندر کنگ.بندر لافت.بندر لنگه.بندرعباس.بیکا.پارسیان.تازیان پایین.تخت.تنب بزرگ.تیرور.جاسک.جناح.حاجی‌آباد.درگهان.دشتی.دهبارز.رویدر.زیارتعلی.سردشت.سرگز احمدی.سندرک.سوزا.سیریک.طبل.فارغان.فین.قشم.قلعه قاضی.کوخردهرنگ.کوهستک.کوهیج.کیش.گروک.گوهران.لمزان.میناب.هرمز.هشتبندی`.split(`.`),همدان:/* @__PURE__ */ `آجین.ازندریان.اسدآباد.برزول.بهار.تویسرکان.جورقان.جوکار.داقداق‌آباد.دمق.دهستان سلگی.رزن.زنگنه.سامن.سرکان.شیرینسو.صالح‌آباد.فامنین.فرسفج.فیروزان.قروه درجزین.قهاوند.کبودرآهنگ.گلتپه.گیان.لالجین.مریانج.ملایر.مهاجران.نهاوند.همدان`.split(`.`),یزد:[`ابرکوه`,`احمدآباد`,`اردکان`,`اشکذر`,`بافق`,`بخ`,`بفروییه`,`بهاباد`,`تفت`,`حمیدیا`,`خضرآباد`,`رضوانشهر`,`زارچ`,`شاهدیه`,`عقدا`,`مروست`,`مهردشت`,`مهریز`,`میبد`,`ندوشن`,`نیر`,`هرات`,`یزد`]};function _(e){return e&&g[e]||[]}const v={province:null,city:null,street:``,plaque:``,unit:``,postalCode:``};var y=/* @__PURE__ */ m({KashiCitySelect:()=>w,KashiCombobox:()=>x,KashiProvinceSelect:()=>S,searchText:()=>b});const b=t=>e(t,{digits:`latin`}).toLowerCase();var x=class extends l{constructor(){super(...arguments),this.selected=null,this.query=``,this.list=null,this.filtered=[],this.typing=!1,this.isOpen=!1,this.active=-1,this.rendered=!1,this.valueSet=!1,this.key=f(`kashi-combo`),this.onOutside=e=>{this.contains(e.target)||this.close()}}get defaultLabel(){return null}get defaultPlaceholder(){return``}connectedCallback(){c(()=>{if(this.isConnected){if(!this.rendered){if(this.list===null&&(this.list=this.readOptions()),Object.prototype.hasOwnProperty.call(this,`value`)){let e=this.value;delete this.value,this.value=e??``}else if(!this.valueSet){let e=this.getAttribute(`value`);this.selected=e?this.find(e):null,this.query=this.selected?.label??``}}this.render()}})}disconnectedCallback(){document.removeEventListener(`pointerdown`,this.onOutside)}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.value=n??``:this.render())}get options(){return this.list??[]}set options(e){this.list=[...e],this.selected&&=this.find(this.selected.value),this.rendered&&this.sync()}get value(){return this.selected?.value??``}set value(e){this.valueSet=!0,this.selected=e?this.find(e):null,this.query=this.selected?.label??``,this.typing=!1,this.rendered&&this.sync()}get selectedOption(){return this.selected}focus(e){this.input?.focus(e)}readOptions(){let e=[];for(let t of[...this.querySelectorAll(`:scope > option, :scope > optgroup > option`)]){let n=t.parentElement?.tagName===`OPTGROUP`?t.parentElement.getAttribute(`label`)??void 0:void 0;e.push({value:t.value,label:t.textContent?.trim()??t.value,description:t.dataset.description,keywords:t.dataset.keywords?.split(/[,،]\s*/),disabled:t.disabled,group:n})}for(let e of[...this.querySelectorAll(`:scope > option, :scope > optgroup`)])e.remove();return e}source(e){return this.options}accepts(e,n){return!n.trim()||[e.label,e.description??``,...e.keywords??[]].some(e=>t(n,e)>0)}find(e){return this.source(``).find(t=>t.value===e)??null}detail(){return{value:this.value,option:this.selected}}render(){let e=this.key,t=this.getAttribute(`aria-label`),n=this.hasAttribute(`label`)?this.getAttribute(`label`):t?null:this.defaultLabel,a=this.hasAttribute(`required`),o=this.hasAttribute(`disabled`),c=`${e}-list`,l=`<div class="k-combobox"><div class="k-input"${o?` data-state="disabled"`:``}><input id="${e}" class="k-input__control" type="text" role="combobox" aria-autocomplete="list" aria-expanded="false" aria-controls="${c}" autocomplete="off" placeholder="${i(this.getAttribute(`placeholder`)??this.defaultPlaceholder)}"${a?` required`:``}${o?` disabled`:``}${!n&&t?` aria-label="${i(t)}"`:``}><button type="button" tabindex="-1" class="k-input__action k-combobox__toggle" aria-label="${i(s().combobox.toggle)}"${o?` disabled`:``}><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 8 4 4 4-4"/></svg></button></div><ul id="${c}" role="listbox" class="k-listbox" hidden style="inset-block-start: calc(100% + 6px)"${n?` aria-label="${i(n)}"`:` aria-labelledby="${e}"`}></ul><span class="k-sr-only" aria-live="polite"></span></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,u({id:e,label:n,required:a,control:l})),this.input=this.querySelector(`input.k-input__control`),this.listbox=this.querySelector(`.k-listbox`),this.live=this.querySelector(`.k-combobox > .k-sr-only`),this.isOpen=!1,this.input.addEventListener(`input`,()=>{this.query=this.input.value,this.typing=!0,this.active=-1,this.open(!1),r(this,`kashi-input`,{query:this.query})}),this.input.addEventListener(`keydown`,e=>this.onKey(e)),this.input.addEventListener(`click`,()=>!this.isOpen&&this.open()),this.input.addEventListener(`blur`,e=>{this.contains(e.relatedTarget)||this.close()}),this.querySelector(`.k-combobox__toggle`).addEventListener(`click`,()=>{this.isOpen?this.close():(this.typing=!1,this.open(),this.input.focus())}),this.listbox.addEventListener(`pointerdown`,e=>e.preventDefault()),this.listbox.addEventListener(`click`,e=>{let t=e.target.closest(`[role="option"]`);t&&t.getAttribute(`aria-disabled`)!==`true`&&this.commit(this.filtered[Number(t.dataset.i)])}),this.listbox.addEventListener(`pointermove`,e=>{let t=e.target.closest(`[role="option"]`);t&&t.getAttribute(`aria-disabled`)!==`true`&&Number(t.dataset.i)!==this.active&&this.setActive(Number(t.dataset.i))}),this.rendered=!0,this.sync()}sync(){!this.typing&&this.input.value!==this.query&&(this.input.value=this.query),n(this.querySelector(`:scope > .k-field`),this.input,this.key,this.getAttribute(`error`),this.getAttribute(`hint`)),this.syncHidden(),this.isOpen&&this.renderList()}syncHidden(){d(this,this.getAttribute(`name`),this.value)}enabled(){return this.filtered.map((e,t)=>e.disabled?-1:t).filter(e=>e>=0)}open(e=!0,t=`selected`){if(!this.hasAttribute(`disabled`)){if(this.isOpen=!0,this.input.setAttribute(`aria-expanded`,`true`),this.listbox.hidden=!1,this.toggleAttribute(`data-open`,!0),this.querySelector(`.k-combobox`).setAttribute(`data-open`,``),this.filter(),e){let e=this.enabled(),n=this.filtered.findIndex(e=>e.value===this.selected?.value);this.active=t===`last`?e.at(-1)??-1:t===`first`||n<0?e[0]??-1:n}this.renderList(),document.addEventListener(`pointerdown`,this.onOutside)}}close(){this.rendered&&(this.isOpen=!1,this.input.setAttribute(`aria-expanded`,`false`),this.input.removeAttribute(`aria-activedescendant`),this.listbox.hidden=!0,this.querySelector(`.k-combobox`).removeAttribute(`data-open`),this.live.textContent=``,document.removeEventListener(`pointerdown`,this.onOutside),this.typing&&(this.typing=!1,this.query=this.selected?.label??``,this.input.value=this.query))}filter(){let e=this.source(this.typing?this.query:``);this.filtered=this.typing?e.filter(e=>this.accepts(e,this.query)):e}renderList(){let e=this.typing?b(this.query.trim()):``,t=t=>{let n=e?b(t).indexOf(e):-1;return n<0?i(t):`${i(t.slice(0,n))}<mark>${i(t.slice(n,n+e.length))}</mark>${i(t.slice(n+e.length))}`},n=`${this.key}-list`,r,o=this.filtered.slice(0,300).map((e,a)=>{let o=e.group&&e.group!==r?`<li role="presentation" class="k-listbox__group">${i(e.group)}</li>`:``;r=e.group;let s=e.value===this.selected?.value;return`${o}<li id="${n}-${a}" data-i="${a}" role="option" aria-selected="${s}"${e.disabled?` aria-disabled="true"`:``}${a===this.active?` data-active`:``} class="k-option"><span class="k-option__body"><span>${t(e.label)}</span>${e.description?`<span class="k-option__desc">${i(e.description)}</span>`:``}</span>${s?`<span class="k-option__check"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m5 10.5 3.2 3L15 7"/></svg></span>`:``}</li>`});this.filtered.length||o.push(`<li class="k-listbox__empty" role="presentation">${i(this.getAttribute(`empty-message`)??s().common.noResults)}</li>`),this.filtered.length>300&&o.push(`<li class="k-listbox__empty" role="presentation">${i(s().combobox.more(a(this,this.filtered.length-300)))}</li>`),this.listbox.innerHTML=o.join(``),this.live.textContent=this.typing?s().common.results(a(this,this.filtered.length)):``,this.setActive(this.active)}setActive(e){this.active=e,this.listbox.querySelector(`[data-active]`)?.removeAttribute(`data-active`);let t=e>=0?this.listbox.querySelector(`[data-i="${e}"]`):null;t?(t.setAttribute(`data-active`,``),t.scrollIntoView?.({block:`nearest`}),this.input.setAttribute(`aria-activedescendant`,t.id)):this.input.removeAttribute(`aria-activedescendant`)}move(e){let t=this.enabled().filter(e=>e<300);if(!t.length)return;let n=t.indexOf(this.active);this.setActive(t[(n+e+t.length)%t.length])}onKey(e){if(e.key===`ArrowDown`)e.preventDefault(),this.isOpen?this.move(1):this.open(!0,e.altKey?`selected`:`first`);else if(e.key===`ArrowUp`)e.preventDefault(),this.isOpen?this.move(-1):this.open(!0,`last`);else if(e.key===`Enter`&&this.isOpen&&this.active>=0)e.preventDefault(),this.commit(this.filtered[this.active]);else if(e.key===`Escape`)this.isOpen?(e.preventDefault(),this.close()):this.input.value&&(e.preventDefault(),this.commit(null));else if((e.key===`Home`||e.key===`End`)&&this.isOpen){e.preventDefault();let t=this.enabled();this.setActive((e.key===`Home`?t[0]:t.at(-1))??-1)}}commit(e){let t=(e?.value??null)!==(this.selected?.value??null);this.selected=e,this.query=e?.label??``,this.typing=!1,this.input.value=this.query,this.close(),this.sync(),t&&r(this,`kashi-change`,this.detail())}};x.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`required`,`disabled`,`name`,`value`,`empty-message`,`aria-label`];var S=class extends x{get defaultLabel(){return s().province.label}get defaultPlaceholder(){return s().province.search}source(){let e=this.getAttribute(`show-capital`)!==`false`;return h.map(t=>({value:t.name,label:t.name,description:e?s().province.capital(t.capital):void 0,keywords:[t.capital]}))}detail(){return{value:this.value,province:h.find(e=>e.name===this.value)??null}}};S.observedAttributes=[...x.observedAttributes,`show-capital`];const C=e=>b(e).replace(/[\s‌]/g,``);var w=class extends x{constructor(){super(...arguments),this.custom=null}get defaultLabel(){return s().city.label}get defaultPlaceholder(){return this.placeholderText()}get province(){return this.getAttribute(`province`)||null}set province(e){e?this.setAttribute(`province`,e):this.removeAttribute(`province`)}get value(){return this.selected?this.selected.value.split(`|`)[1]:``}set value(e){this.valueSet=!0,this.custom=null;let t=this.source(``),n=this.province,r=e?t.find(t=>t.label===e&&(!n||t.value.startsWith(`${n}|`)))??null:null;e&&!r&&(this.custom=e,r={value:`custom|${e}`,label:e,description:s().city.outside}),this.selected=r,this.query=r?.label??``,this.isConnected&&this.querySelector(`.k-combobox`)&&this.sync()}find(e){return this.value=e,this.selected}attributeChangedCallback(e,t,n){if(e!==`province`)return super.attributeChangedCallback(e,t,n);if(t!==n){if(this.selected){let e=this.value;!n||!_(n).includes(e)?(this.selected=null,this.query=``,this.custom=null):this.selected={value:`${n}|${e}`,label:e}}this.querySelector(`.k-combobox`)&&(this.input.placeholder=this.getAttribute(`placeholder`)??this.placeholderText(),this.input.value=this.query,this.sync())}}connectedCallback(){super.connectedCallback()}placeholderText(){return this.province?s().city.search:s().city.hint}source(e){let t=this.province,n=t?_(t).map(e=>({value:`${t}|${e}`,label:e})):Object.entries(g).flatMap(([e,t])=>t.map(t=>({value:`${e}|${t}`,label:t,description:e})));this.custom&&n.unshift({value:`custom|${this.custom}`,label:this.custom,description:s().city.outside});let r=e.trim();return this.getAttribute(`allow-custom`)!==`false`&&r&&r!==this.custom&&!n.some(e=>C(e.label)===C(r))&&n.push({value:`custom|${r}`,label:r,description:s().city.custom}),n}accepts(e,t){return e.value.startsWith(`custom|`)||[e.label,e.description??``].some(e=>C(e).includes(C(t)))}commit(e){this.custom=e?.value.startsWith(`custom|`)?e.label:null,super.commit(e)}detail(){let[e]=this.selected?this.selected.value.split(`|`):[null];return{value:this.value,province:e===`custom`?null:e}}};w.observedAttributes=[...x.observedAttributes,`province`,`allow-custom`],o(`kashi-combobox`,x,`block`),o(`kashi-province-select`,S,`block`),o(`kashi-city-select`,w,`block`);export{h as a,_ as i,b as n,v as r,y as t};
@@ -0,0 +1 @@
1
+ import{N as e,c as t,d as n,j as r,l as i,o as a,p as o,s,t as c,y as l}from"./base-BqFAMlwG.js";import{t as u}from"./search-BvShDz2X.js";const d=e=>e.replace(/[يى]/g,`ی`).replace(/ك/g,`ک`).replace(/[‌\s]+/g,` `).trim().toLowerCase(),f=e=>(e??``).split(/[,،]/).map(e=>e.trim()).filter(Boolean),p=`<svg viewBox="0 0 20 20" width="20" height="20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><circle cx="9.1" cy="9.1" r="6.2"/><path d="m14 14 3.3 3.3"/></svg>`;var m=class extends c{constructor(){super(...arguments),this.lo=0,this.hi=0,this.ready=!1,this.key=l(`kashi-price`)}connectedCallback(){this.ready||this.read(this.getAttribute(`value`)),this.render()}attributeChangedCallback(e,t,n){this.ready&&t!==n&&(e===`value`&&this.read(n),this.render())}n(e,t){let n=this.getAttribute(e);return n===null||n===``||Number.isNaN(Number(n))?t:Number(n)}get min(){return this.n(`min`,0)}get max(){return this.n(`max`,1e8)}get step(){return this.n(`step`,1e3)}read(e){let t=f(e).map(Number);[this.lo,this.hi]=[t[0]??this.min,t[1]??this.max]}get value(){return[this.lo,this.hi]}set value(e){[this.lo,this.hi]=e,this.ready&&this.render()}fmt(e){return r(e,{digits:s(this)})}render(){let r=o().priceRange,a=this.getAttribute(`label`),s=this.getAttribute(`unit`)??(n()===`en`?`Toman`:`تومان`),c=this.getAttribute(`name`),l=this.hasAttribute(`disabled`)?` disabled`:``,u=e=>`${(e-this.min)/(this.max-this.min)*100}%`,d=e=>`<label class="k-price-range__field"><span class="k-price-range__edge">${i(e?r.to:r.from)}</span><input class="k-price-range__input" data-i="${e}" inputmode="numeric" dir="ltr" autocomplete="off" value="${i(this.fmt(e?this.hi:this.lo))}" aria-label="${i(`${e?r.to:r.from}${a?` ${a}`:``}`)}"${l}><span class="k-price-range__unit">${i(s)}</span></label>`,f=e=>`<input type="range" class="k-slider__input" data-w="${e}" min="${this.min}" max="${this.max}" step="${this.step}" value="${e===`lo`?this.lo:this.hi}"${c?` name="${i(`${c}_${e===`lo`?`min`:`max`}`)}"`:``} aria-label="${i(`${e===`lo`?r.from:r.to}${a?` ${a}`:``}`)}" aria-valuetext="${i(`${this.fmt(e===`lo`?this.lo:this.hi)} ${s}`)}"${l}>`;this.innerHTML=`<div class="k-price-range" role="group" ${a?`aria-labelledby="${this.key}"`:`aria-label="${i(r.range)}"`}>${a?`<span class="k-label k-price-range__label" id="${this.key}">${i(a)}</span>`:``}<div class="k-price-range__fields">${d(0)}${d(1)}</div><div class="k-slider k-price-range__slider" data-range=""><div class="k-slider__track" style="--_from: ${u(this.lo)}; --_to: ${u(this.hi)}"><span class="k-slider__fill" aria-hidden="true"></span>${f(`lo`)}${f(`hi`)}</div></div><div class="k-price-range__ends" aria-hidden="true"><span>${i(r.min)}</span><span>${i(r.max)}</span></div></div>`,this.ready=!0;let p=()=>{let e=this.querySelector(`.k-slider__track`);e.style.setProperty(`--_from`,u(this.lo)),e.style.setProperty(`--_to`,u(this.hi)),this.querySelectorAll(`.k-slider__input`).forEach(e=>{e.value=String(e.dataset.w===`lo`?this.lo:this.hi),e.setAttribute(`aria-valuetext`,`${this.fmt(Number(e.value))} ${s}`)}),this.querySelectorAll(`.k-price-range__input`).forEach(e=>{document.activeElement!==e&&(e.value=this.fmt(e.dataset.i===`1`?this.hi:this.lo))}),t(this,`kashi-change`,{value:this.value})};this.querySelectorAll(`.k-slider__input`).forEach(e=>e.addEventListener(`input`,()=>{let t=Number(e.value);e.dataset.w===`lo`?this.lo=Math.min(t,this.hi):this.hi=Math.max(t,this.lo),p()})),this.querySelectorAll(`.k-price-range__input`).forEach(t=>{t.addEventListener(`input`,()=>{let n=e(t.value).replace(/\D/g,``);t.value=n?this.fmt(Number(n)):``});let n=()=>{let n=Math.round(Number(e(t.value).replace(/\D/g,``)||0)/this.step)*this.step;n=Math.min(this.max,Math.max(this.min,n)),t.dataset.i===`1`?this.hi=Math.max(n,this.lo):this.lo=Math.min(n,this.hi),t.value=this.fmt(t.dataset.i===`1`?this.hi:this.lo),p()};t.addEventListener(`blur`,n),t.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),n())})})}};m.observedAttributes=[`label`,`min`,`max`,`step`,`value`,`unit`,`name`,`disabled`];var h=class extends c{constructor(){super(...arguments),this.opts=[],this.sel=[],this.ready=!1,this.key=l(`kashi-swatch`)}connectedCallback(){this.ready||(this.opts=[...this.querySelectorAll(`option`)].map(e=>({value:e.value,label:e.textContent?.trim()??e.value,color:e.dataset.color??e.value,disabled:e.disabled})),this.sel=f(this.getAttribute(`value`))),this.render()}attributeChangedCallback(e,t,n){this.ready&&t!==n&&(e===`value`&&(this.sel=f(n)),this.render())}get value(){return[...this.sel]}set value(e){this.sel=[...e],this.ready&&this.render()}render(){let e=this.hasAttribute(`single`),n=this.getAttribute(`size`),r=this.getAttribute(`label`),a=this.getAttribute(`name`)??(e?this.key:``);this.innerHTML=`<fieldset class="k-swatches${n===`sm`||n===`lg`?` k-swatches--${n}`:``}">${r?`<legend class="k-label k-swatches__legend">${i(r)}</legend>`:``}<div class="k-swatches__grid"${e?` role="radiogroup"`:``}>${this.opts.map(t=>{let n=this.sel.includes(t.value);return`<label class="k-swatch"${t.disabled?` data-disabled`:``}><input type="${e?`radio`:`checkbox`}" class="k-sr-only"${a?` name="${i(a)}"`:``} value="${i(t.value)}"${n?` checked`:``}${t.disabled?` disabled`:``}><span class="k-swatch__color" style="--_c: ${i(t.color)}" aria-hidden="true"><svg class="k-swatch__check" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="m5 10.5 3.2 3L15 7"/></svg></span><span class="k-swatch__label">${i(t.label)}${n?`<span class="k-sr-only">، ${i(o().swatch.selected)}</span>`:``}</span></label>`}).join(``)}</div></fieldset>`,this.ready=!0,this.querySelectorAll(`input`).forEach(n=>{n.addEventListener(`click`,r=>{e&&this.sel[0]===n.value?(r.preventDefault(),this.sel=[]):this.sel=e?[n.value]:this.sel.includes(n.value)?this.sel.filter(e=>e!==n.value):[...this.sel,n.value],this.render(),this.querySelector(`input[value="${CSS.escape(n.value)}"]`)?.focus(),t(this,`kashi-change`,{value:this.value})})})}};h.observedAttributes=[`label`,`value`,`single`,`size`,`name`];var g=class extends c{constructor(){super(...arguments),this.q=``,this.open=!1,this.active=-1,this.ready=!1,this.key=l(`kashi-search`),this.outside=e=>{this.contains(e.target)||this.setOpen(!1)}}connectedCallback(){this.ready||this.render(),document.addEventListener(`pointerdown`,this.outside)}disconnectedCallback(){document.removeEventListener(`pointerdown`,this.outside)}attributeChangedCallback(){this.ready&&this.paint()}get value(){return this.q}set value(e){this.q=e;let t=this.querySelector(`input`);t&&(t.value=e),this.paint()}get recent(){let e=this.getAttribute(`storage-key`);if(e)try{return JSON.parse(localStorage.getItem(e)??`[]`)}catch{return[]}return f(this.getAttribute(`recent`))}set recent(e){let t=this.getAttribute(`storage-key`);if(t)try{localStorage.setItem(t,JSON.stringify(e.slice(0,8)))}catch{}else this.setAttribute(`recent`,e.join(`،`))}get hits(){return d(this.q)?u(f(this.getAttribute(`suggestions`)),this.q).slice(0,8):[]}render(){let e=o().searchSuggest,n=this.getAttribute(`name`)??`q`,r=this.getAttribute(`action`);this.innerHTML=`<form class="k-search-suggest" role="search"${r?` action="${i(r)}"`:``}><div class="k-search-suggest__box">${p}<input type="search" class="k-search-suggest__input" name="${i(n)}" role="combobox" aria-autocomplete="list" aria-expanded="false" aria-controls="${this.key}" autocomplete="off" enterkeyhint="search" aria-label="${i(this.getAttribute(`label`)??e.label)}" placeholder="${i(this.getAttribute(`placeholder`)??``)}"></div><div class="k-search-suggest__panel" id="${this.key}" hidden></div></form>`,this.ready=!0;let a=this.querySelector(`input`),s=this.querySelector(`form`);a.addEventListener(`focus`,()=>this.setOpen(!0)),a.addEventListener(`input`,()=>{this.q=a.value,this.active=-1,this.setOpen(!0),t(this,`kashi-change`,{value:this.q})}),a.addEventListener(`keydown`,e=>{let t=this.hits;e.key===`Escape`?this.open?(e.preventDefault(),this.setOpen(!1)):a.value=this.q=``:t.length&&(e.key===`ArrowDown`&&(e.preventDefault(),this.active=(this.active+1)%t.length,this.setOpen(!0)),e.key===`ArrowUp`&&(e.preventDefault(),this.active=this.active<=0?t.length-1:this.active-1,this.paint()))}),s.addEventListener(`submit`,e=>{let t=this.hits,n=this.active>=0&&t[this.active]||a.value;r||e.preventDefault(),this.search(n,!r)}),this.paint()}search(e,n=!0){let r=e.trim();if(!r)return;let i=this.querySelector(`input`);i.value=this.q=r,this.recent=[r,...this.recent.filter(e=>d(e)!==d(r))],this.setOpen(!1),t(this,`kashi-search`,{query:r}),!n&&this.getAttribute(`action`)&&this.querySelector(`form`).requestSubmit?.()}setOpen(e){this.open=e,this.paint()}paint(){let e=this.querySelector(`.k-search-suggest__panel`),t=this.querySelector(`input`);if(!e||!t)return;let n=o().searchSuggest,r=this.hits,a=this.recent,s=f(this.getAttribute(`popular`)),c=!this.q.trim()&&(a.length>0||s.length>0),l=this.open&&(r.length>0||c);if(e.hidden=!l,t.setAttribute(`aria-expanded`,String(l)),t.toggleAttribute(`aria-activedescendant`,!1),!l)return;let u=(e,t)=>`<li><button type="button" class="k-search-suggest__chip" data-q="${i(e)}">${t}${i(e)}</button></li>`;r.length?(e.innerHTML=`<ul role="listbox" aria-label="${i(n.suggestions)}" class="k-search-suggest__list">${r.map((e,t)=>`<li id="${this.key}-${t}" role="option" aria-selected="${t===this.active}" class="k-option" data-q="${i(e)}"${t===this.active?` data-active`:``}>${p}<span class="k-option__label">${i(e)}</span></li>`).join(``)}</ul>`,this.active>=0&&t.setAttribute(`aria-activedescendant`,`${this.key}-${this.active}`)):e.innerHTML=`${a.length?`<section class="k-search-suggest__section"><div class="k-search-suggest__head"><b>${i(n.recent)}</b><button type="button" class="k-btn k-btn--link k-btn--sm" data-clear>${i(n.clear)}</button></div><ul class="k-search-suggest__chips">${a.map(e=>u(e,`<svg viewBox="0 0 20 20" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3.3 10a6.7 6.7 0 1 0 1.9-4.7M3.2 2.9v2.6h2.6M10 6.6V10l2.3 1.5"/></svg>`)).join(``)}</ul></section>`:``}${s.length?`<section class="k-search-suggest__section"><div class="k-search-suggest__head"><b>${i(n.popular)}</b></div><ul class="k-search-suggest__chips">${s.map(e=>u(e,`<svg viewBox="0 0 20 20" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m2.75 13.5 4.6-4.6 3.2 3.2 6.2-6.2M12.75 5.9h4v4"/></svg>`)).join(``)}</ul></section>`:``}`,e.querySelectorAll(`[data-q]`).forEach(e=>{e.addEventListener(`mousedown`,e=>e.preventDefault()),e.addEventListener(`click`,()=>this.search(e.dataset.q,!this.getAttribute(`action`)))}),e.querySelector(`[data-clear]`)?.addEventListener(`click`,()=>{this.recent=[],this.paint()})}};g.observedAttributes=[`placeholder`,`popular`,`suggestions`,`recent`,`storage-key`,`label`,`name`,`action`],a(`kashi-price-range`,m,`block`),a(`kashi-swatch-group`,h,`block`),a(`kashi-search-suggest`,g,`block`);export{m as KashiPriceRange,g as KashiSearchSuggest,h as KashiSwatchGroup};
@@ -1 +1 @@
1
- import{d as e,i as t,j as n,l as r,m as i,n as a,o,p as s,r as c,s as l,t as u}from"./base-D4tCOysh.js";import{t as d}from"./relative-OC1fV3Xh.js";import{f,i as p,m,o as h,p as g,s as _,u as v}from"./parts-5fVaWtRe.js";var y=class extends u{constructor(){super(...arguments),this.built=!1}connectedCallback(){c(()=>{this.isConnected&&(this.built||(this.built=!0,this.build()),this.update())})}attributeChangedCallback(e,t,n){this.built&&t!==n&&this.update()}},b=class extends y{build(){let e=f(this,`icon`)[0];if(this.box=document.createElement(`span`),e){let t=document.createElement(`span`);t.className=`k-badge__icon`,t.setAttribute(`aria-hidden`,`true`),t.append(e),this.box.append(t)}this.text=document.createElement(`span`),this.text.style.display=`contents`,this.text.append(...this.childNodes),this.box.append(this.text),this.append(this.box),this.box.addEventListener(`click`,e=>{if(!e.target.closest(`.k-badge__remove`))return;let t=new CustomEvent(`kashi-remove`,{bubbles:!0,cancelable:!0,detail:{value:this.text.textContent?.trim()??``}});this.dispatchEvent(t)&&this.remove()})}update(){let e=this.getAttribute(`tone`)??`neutral`,n=this.getAttribute(`variant`)??`soft`,i=this.getAttribute(`size`)??`md`,a=t(this,`removable`);this.box.className=p(`k-badge`,e!==`neutral`&&`k-badge--${e}`,n!==`soft`&&`k-badge--${n}`,i!==`md`&&`k-badge--${i}`,t(this,`square`)&&`k-badge--square`,a&&`k-badge--removable`),this.box.dataset.tone=e,this.box.dataset.variant=n;let o=this.box.querySelector(`:scope > .k-badge__dot`);t(this,`dot`)&&!o?this.box.insertAdjacentHTML(`afterbegin`,`<span class="k-badge__dot" aria-hidden="true"></span>`):t(this,`dot`)||o?.remove();let c=this.box.querySelector(`:scope > .k-badge__remove`);if(a){let e=this.text.textContent?.trim()??``,t=this.getAttribute(`remove-label`)??(e?s().common.remove(e):s().common.removeShort);c?c.setAttribute(`aria-label`,t):this.box.insertAdjacentHTML(`beforeend`,`<button type="button" class="k-badge__remove" aria-label="${r(t)}"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="m6 6 8 8M14 6l-8 8"/></svg></button>`)}else c?.remove()}};b.observedAttributes=[`tone`,`variant`,`size`,`dot`,`square`,`removable`,`remove-label`];const x=[`brand`,`info`,`success`,`warning`,`error`],S=(e,t=2)=>e.trim().split(/\s+/).slice(0,t).map(e=>e[0]??``).join(`‌`).toUpperCase();function C(e){let t=0;for(let n of e.trim())t=t*31+n.codePointAt(0)>>>0;return x[t%x.length]}var w=class extends u{constructor(){super(...arguments),this.failed=!1}connectedCallback(){this.render()}attributeChangedCallback(e,t,n){t!==n&&this.isConnected&&(e===`src`&&(this.failed=!1),this.render())}render(){let e=this.getAttribute(`name`)??``,n=this.getAttribute(`size`)??`md`,i=this.getAttribute(`color`),a=i===`auto`?C(e):i??(t(this,`brand`)?`brand`:`neutral`),o=this.getAttribute(`status`),c=o?this.getAttribute(`status-label`)??s().avatar[o]:null,l=this.getAttribute(`src`),u=c?`${e}${s().common.list}${c}`:e,d=l&&!this.failed?`<img class="k-avatar__image" src="${r(l)}" alt="">`:`<span aria-hidden="true">${r(S(e,n===`xs`||n===`sm`?1:2))}</span>`;this.innerHTML=`<span role="img" aria-label="${r(u)}" data-tone="${a}" class="${p(`k-avatar`,n!==`md`&&`k-avatar--${n}`,t(this,`square`)&&`k-avatar--square`,a!==`neutral`&&`k-avatar--${a}`)}">${d}${o?`<span class="k-avatar__status k-avatar__status--${o}" aria-hidden="true"></span>`:``}</span>`,this.querySelector(`img`)?.addEventListener(`error`,()=>{this.failed=!0,this.render()},{once:!0})}};w.observedAttributes=[`name`,`src`,`size`,`square`,`brand`,`color`,`status`,`status-label`];var T=class extends y{build(){this.box=document.createElement(`div`),this.box.setAttribute(`role`,`group`),this.box.className=`k-avatar-group`,this.box.append(...this.childNodes),this.append(this.box)}update(){this.box.querySelector(`:scope > [data-more]`)?.remove();let e=[...this.box.children].filter(e=>e.tagName===`KASHI-AVATAR`||e.classList.contains(`k-avatar`)),t=v(this,`max`);e.forEach((e,n)=>e.hidden=!!t&&n>=t);let n=t?Math.max(0,e.length-t):0;if(!n)return;let a=this.getAttribute(`size`)??`md`,o=this.getAttribute(`more-label`)?.replace(`{n}`,i(this,n))??s().avatar.more(i(this,n));this.box.insertAdjacentHTML(`beforeend`,`<span data-more role="img" aria-label="${r(o)}" class="${p(`k-avatar`,a!==`md`&&`k-avatar--${a}`)}"><span aria-hidden="true">+${i(this,n)}</span></span>`)}};T.observedAttributes=[`max`,`size`,`more-label`];var E=class extends u{connectedCallback(){this.render()}attributeChangedCallback(){this.isConnected&&this.render()}render(){let e=this.getAttribute(`label`),n=t(this,`vertical`);this.innerHTML=`<div role="separator"${n?` aria-orientation="vertical"`:``} class="${p(`k-divider`,n&&`k-divider--vertical`)}">${e?`<span>${r(e)}</span>`:``}</div>`}};E.observedAttributes=[`label`,`vertical`];const D=e=>e===null?null:/^\d+(\.\d+)?$/.test(e)?`${e}px`:e;var O=class extends u{connectedCallback(){this.render()}attributeChangedCallback(){this.isConnected&&this.render()}render(){let e=D(this.getAttribute(`width`)),n=t(this,`circle`),i=D(this.getAttribute(`height`))??(n?e:null),a=[e&&`--k-skeleton-width: ${e}`,i&&`--k-skeleton-height: ${i}`].filter(Boolean).join(`; `),o=a?` style="${r(a)}"`:``,s=v(this,`lines`,0);this.innerHTML=s>0?`<span class="k-skeleton-group" aria-hidden="true"${o}>${`<span class="k-skeleton k-skeleton--text"></span>`.repeat(Math.min(50,s))}</span>`:`<span class="${p(`k-skeleton`,n&&`k-skeleton--circle`)}" aria-hidden="true"${o}></span>`}};O.observedAttributes=[`width`,`height`,`circle`,`lines`];var k=class extends y{build(){let e=f(this,`media`),t=f(this,`actions`),n=f(this,`footer`),r=m(this);this.box=document.createElement(`article`);for(let t of e)t.classList.add(`k-card__media`),t instanceof HTMLImageElement&&!t.style.aspectRatio&&(t.style.aspectRatio=`16 / 9`),this.box.append(t);if(this.header=document.createElement(`header`),this.header.innerHTML=`<div class="k-card__heading"></div>`,t.length){let e=document.createElement(`div`);e.className=`k-card__actions`,e.append(...t),this.header.append(e)}if(this.box.append(this.header),h(r)){let e=document.createElement(`div`);e.className=`k-card__body`,e.append(...r),this.box.append(e)}if(n.length){let e=document.createElement(`footer`);e.className=`k-card__footer`,e.append(...n),this.box.append(e)}this.append(this.box)}update(){let e=this.getAttribute(`variant`)??`outlined`,n=this.getAttribute(`padding`)??`md`;this.box.className=p(`k-card`,t(this,`flat`)&&`k-card--flat`,t(this,`interactive`)&&`k-card--interactive`,e!==`outlined`&&`k-card--${e}`,n!==`md`&&`k-card--pad-${n}`),this.box.dataset.variant=e;let i=this.getAttribute(`heading`),a=this.getAttribute(`description`),o=!!this.header.querySelector(`.k-card__actions`);this.header.className=p(`k-card__header`,o&&`k-card__header--actions`),this.header.hidden=!i&&!a&&!o;let s=Math.min(6,Math.max(1,v(this,`heading-level`,3))),c=this.header.querySelector(`.k-card__heading`);c.innerHTML=`${i?`<h${s} class="k-card__title">${r(i)}</h${s}>`:``}${a?`<p class="k-card__description">${r(a)}</p>`:``}`}};k.observedAttributes=[`heading`,`description`,`heading-level`,`variant`,`padding`,`flat`,`interactive`];const A=e=>_(e,1.5),j={noData:A(`<path d="M7.25 2.75h5.5c3.6 0 4.5.9 4.5 4.5v5.5c0 3.6-.9 4.5-4.5 4.5h-5.5c-3.6 0-4.5-.9-4.5-4.5v-5.5c0-3.6.9-4.5 4.5-4.5Z"/><path d="M2.75 10.75h3.1c.55 0 1 .3 1.25.75l.5.95c.25.45.7.75 1.25.75h2.3c.55 0 1-.3 1.25-.75l.5-.95c.25-.45.7-.75 1.25-.75h3.1"/>`),noResults:A(`<circle cx="9.1" cy="9.1" r="6.2"/><path d="m14.9 14.9 2.3 2.3M7.2 7.2l3.8 3.8M11 7.2l-3.8 3.8"/>`),error:A(`<path d="M8.33 3.9c.74-1.3 2.6-1.3 3.34 0l5.6 9.75c.74 1.3-.2 2.85-1.67 2.85H4.4c-1.48 0-2.41-1.56-1.67-2.85Z"/><path d="M10 7.9v3.1M10 13.6v.01"/>`),offline:A(`<path d="M2.75 7.6a10.5 10.5 0 0 1 14.5 0M5.2 10.3a7 7 0 0 1 9.6 0M7.7 12.95a3.5 3.5 0 0 1 4.6 0M10 15.75v.01"/><path d="m3 3 14 14"/>`),noAccess:A(`<path d="M7.25 8.25h5.5c2.6 0 3.25.65 3.25 3.25v2.75c0 2.6-.65 3.25-3.25 3.25h-5.5C4.65 17.5 4 16.85 4 14.25V11.5c0-2.6.65-3.25 3.25-3.25Z"/><path d="M6.9 8.3V6.4a3.1 3.1 0 0 1 6.2 0v1.9M10 11.6v2.2"/>`),done:A(`<circle cx="10" cy="10" r="7.25"/><path d="m6.75 10.1 2.2 2.2 4.3-4.5"/>`)},M=[`noData`,`noResults`,`error`,`offline`,`noAccess`,`done`],N=e=>{if(!e)return null;let t=e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase());return M.includes(t)?t:null};var P=class extends y{constructor(){super(...arguments),this.customIcon=null,this.actions=null}build(){this.customIcon=f(this,`icon`)[0]??null;let e=f(this,`actions`);this.box=document.createElement(`div`),this.box.innerHTML=`<span class="k-empty__icon" aria-hidden="true"></span><p class="k-empty__title"></p><p class="k-empty__description"></p>`,this.customIcon&&this.box.firstElementChild.append(this.customIcon);let t=m(this);(e.length||h(t))&&(this.actions=document.createElement(`div`),this.actions.className=`k-empty__actions`,this.actions.append(...e,...h(t)?t:[]),this.box.append(this.actions)),this.replaceChildren(this.box)}update(){let e=N(this.getAttribute(`preset`)),n=this.getAttribute(`size`)??`md`,r=e?s().empty[e]:void 0;this.box.className=p(`k-empty`,n!==`md`&&`k-empty--${n}`,t(this,`bordered`)&&`k-empty--bordered`),e?this.box.dataset.preset=e:delete this.box.dataset.preset,e===`error`||e===`offline`?this.box.setAttribute(`role`,`status`):this.box.removeAttribute(`role`);let i=this.box.querySelector(`.k-empty__icon`);this.customIcon||(i.innerHTML=e?j[e]:``),i.hidden=!i.firstChild;let a=this.getAttribute(`heading`)??r?.[0]??``,o=this.getAttribute(`description`)??r?.[1]??``,c=this.box.querySelector(`.k-empty__title`),l=this.box.querySelector(`.k-empty__description`);c.textContent=a,c.hidden=!a,l.textContent=o,l.hidden=!o}};P.observedAttributes=[`preset`,`heading`,`description`,`size`,`bordered`];const F=e=>_(e?`<path d="M10 15V5m0 0-4 4m4-4 4 4"/>`:`<path d="M10 5v10m0 0-4-4m4 4 4-4"/>`,1.8);var I=class extends y{build(){let e=f(this,`icon`)[0],t=m(this);if(this.box=document.createElement(`div`),this.box.className=`k-stat`,this.box.innerHTML=`<div class="k-stat__head"><p class="k-stat__label"></p></div><p class="k-stat__value"><span></span><span class="k-stat__unit"></span></p><div class="k-stat__foot"></div>`,e){let t=document.createElement(`span`);t.className=`k-stat__icon`,t.setAttribute(`aria-hidden`,`true`),t.append(e),this.box.firstElementChild.prepend(t)}if(h(t)){let e=document.createElement(`div`);e.className=`k-stat__chart`,e.append(...t),this.box.append(e)}this.replaceChildren(this.box)}update(){let e=s(),n=v(this,`change`);this.box.querySelector(`.k-stat__label`).textContent=this.getAttribute(`label`)??``;let a=this.getAttribute(`value`)??``;this.box.querySelector(`.k-stat__value > span`).textContent=/^-?[\d.,]+$/.test(a)?i(this,a):a;let o=this.box.querySelector(`.k-stat__unit`);o.textContent=this.getAttribute(`unit`)??``,o.hidden=!o.textContent,t(this,`loading`)?this.box.setAttribute(`aria-busy`,`true`):this.box.removeAttribute(`aria-busy`);let c=n===void 0?null:n>0?`up`:n<0?`down`:`flat`,l=c===`flat`?`flat`:c===`up`===t(this,`invert-trend`)?`down`:`up`,u=this.getAttribute(`up-label`)??e.stat.up,d=this.getAttribute(`down-label`)??e.stat.down,f=this.getAttribute(`flat-label`)??e.stat.flat,p=n===void 0?``:e.common.percent(i(this,Math.abs(Math.round(n*10)/10)).replace(`.`,e.common.decimal)),m=this.getAttribute(`caption`),h=this.box.querySelector(`.k-stat__foot`);h.hidden=!c&&!m,h.innerHTML=`${c?`<span class="k-trend k-trend--${l}">${c===`flat`?``:F(c===`up`)}<span aria-hidden="true">${r(c===`flat`?f:p)}</span><span class="k-sr-only">${r(c===`flat`?f:`${p} ${c===`up`?u:d}`)}</span></span>`:``}${m?`<span>${r(m)}</span>`:``}`}};I.observedAttributes=[`label`,`value`,`unit`,`change`,`invert-trend`,`caption`,`loading`,`up-label`,`down-label`,`flat-label`];const L={neutral:a.info,brand:a.info,info:a.info,success:a.success,warning:a.warning,error:a.error};var R=class extends y{constructor(){super(...arguments),this.customIcon=null}build(){this.customIcon=f(this,`icon`)[0]??null;let e=f(this,`actions`),t=m(this);this.box=document.createElement(`div`),this.box.innerHTML=`<span class="k-alert__icon" aria-hidden="true"></span><div class="k-alert__content"><p class="k-alert__title"></p></div>`;let n=this.box.querySelector(`.k-alert__content`);if(h(t)){let e=document.createElement(`div`);e.className=`k-alert__description`,e.append(...t),n.append(e)}if(e.length){let t=document.createElement(`div`);t.className=`k-alert__actions`,t.append(...e),n.append(t)}this.customIcon&&this.box.firstElementChild.append(this.customIcon),this.replaceChildren(this.box),this.box.addEventListener(`click`,e=>{e.target.closest(`.k-alert__close`)&&this.close()})}update(){let e=this.getAttribute(`tone`)??`neutral`;this.box.className=p(`k-alert`,e!==`neutral`&&`k-alert--${e}`,t(this,`tinted`)&&`k-alert--tinted`,this.getAttribute(`layout`)===`banner`&&`k-alert--banner`,this.getAttribute(`size`)===`sm`&&`k-alert--sm`),this.box.dataset.tone=e,this.box.setAttribute(`role`,e===`error`||e===`warning`?`alert`:`status`);let n=this.box.querySelector(`.k-alert__icon`);n.hidden=this.getAttribute(`icon`)===`false`,this.customIcon||(n.innerHTML=L[e]??a.info);let r=this.box.querySelector(`.k-alert__title`);r.textContent=this.getAttribute(`heading`)??``,r.hidden=!r.textContent;let i=this.box.querySelector(`:scope > .k-alert__close`);t(this,`dismissible`)?(i||=(this.box.insertAdjacentHTML(`beforeend`,`<button type="button" class="k-btn k-btn--tertiary k-btn--icon k-btn--sm k-alert__close">${a.close}</button>`),this.box.querySelector(`:scope > .k-alert__close`)),i.setAttribute(`aria-label`,this.getAttribute(`close-label`)??s().alert.close)):i?.remove()}close(){let e=new CustomEvent(`kashi-close`,{bubbles:!0,cancelable:!0,detail:{}});this.dispatchEvent(e)&&(this.hidden=!0)}};R.observedAttributes=[`tone`,`heading`,`tinted`,`layout`,`size`,`dismissible`,`close-label`,`icon`];var z=class extends u{constructor(){super(...arguments),this.box=null}connectedCallback(){this.box||(this.box=document.createElement(`div`),this.box.className=`k-meter`,this.box.innerHTML=`<div class="k-meter__head"><span class="k-meter__label"></span><span class="k-meter__value"></span></div><div class="k-meter__track" role="meter" aria-valuemin="0"><span class="k-meter__fill"></span><span class="k-meter__mark" aria-hidden="true"></span></div><p class="k-meter__status" aria-hidden="true"></p>`,this.replaceChildren(this.box)),this.update()}attributeChangedCallback(){this.box&&this.update()}update(){let e=s(),t=v(this,`max`,100)||100,a=v(this,`warning`,t*.8),o=v(this,`critical`,t*.95),c=Math.min(t,Math.max(0,v(this,`value`,0))),u=c>=o?`critical`:c>=a?`warning`:`ok`,d=Math.round(c/t*100),f=this.getAttribute(`${u}-label`)??e.meter[u],p=this.getAttribute(`unit`),m=e=>`${n(Math.round(e*100)/100,{digits:l(this)})}${p?` ${p}`:``}`,h=this.getAttribute(`of`),g=this.getAttribute(`label`)??``,y=this.box;y.dataset.status=u,y.querySelector(`.k-meter__label`).textContent=g,y.querySelector(`.k-meter__value`).innerHTML=`${r(m(c))} <span>${r(h==null?s().common.of(``,m(t)).trim():`${h} ${m(t)}`)}</span>`;let b=y.querySelector(`.k-meter__track`);b.setAttribute(`aria-valuenow`,String(c)),b.setAttribute(`aria-valuemax`,String(t)),b.setAttribute(`aria-valuetext`,`${h?`${m(c)} ${h} ${m(t)}`:e.common.of(m(c),m(t))}${e.common.list}${e.common.percent(i(this,d))}${e.common.list}${f}`),g&&b.setAttribute(`aria-label`,g),y.querySelector(`.k-meter__fill`).style.inlineSize=`${d}%`,y.querySelector(`.k-meter__mark`).style.insetInlineStart=`${a/t*100}%`,y.querySelector(`.k-meter__status`).innerHTML=`${_(`<path d="${u===`ok`?`m5 10.5 3.2 3L15 7`:`M10 3 2.5 16.5h15ZM10 8v4M10 14.5h.01`}"/>`,1.8)}${r(f)} · ${r(e.common.percent(i(this,d)))}`}};z.observedAttributes=[`label`,`value`,`max`,`warning`,`critical`,`unit`,`of`,`ok-label`,`warning-label`,`critical-label`,`digits`];var B=class extends u{constructor(){super(...arguments),this.kind=``}connectedCallback(){this.update()}attributeChangedCallback(){this.isConnected&&this.update()}update(){let e=s(),n=v(this,`max`,100)||100,r=v(this,`value`),a=r===void 0?void 0:Math.max(0,Math.min(100,r/n*100)),o=a===void 0?void 0:e.common.percent(i(this,Math.round(a))),c=this.getAttribute(`label`),l=this.getAttribute(`size`)??`md`,u=this.getAttribute(`tone`)??`brand`,d=this.getAttribute(`variant`)===`circular`,f=t(this,`show-value`),m=`${d}-${!!c}`;m!==this.kind&&(this.kind=m,this.innerHTML=d?`<div role="progressbar" aria-valuemin="0"><svg viewBox="0 0 40 40" aria-hidden="true"><circle class="k-progress-ring__track" cx="20" cy="20" r="16"/><circle class="k-progress-ring__bar" cx="20" cy="20" r="16"/></svg><span class="k-progress-ring__value" aria-hidden="true"></span></div>`:`${c?`<div class="k-progress-field"><div class="k-progress-field__head" aria-hidden="true"><span class="k-progress-field__label"></span><span class="k-progress-field__value"></span></div>`:``}<div role="progressbar" aria-valuemin="0"><div class="k-progress__bar"></div></div>${c?`</div>`:``}`);let h=this.querySelector(`[role="progressbar"]`);h.setAttribute(`aria-valuemax`,String(n));for(let[e,t]of[[`aria-valuenow`,r===void 0?null:String(r)],[`aria-valuetext`,o??null],[`aria-label`,this.getAttribute(`aria-label`)??c]])t===null?h.removeAttribute(e):h.setAttribute(e,t);if(d){let e=2*Math.PI*16;h.className=p(`k-progress-ring`,l!==`md`&&`k-progress-ring--${l}`,u!==`brand`&&`k-progress--${u}`,a===void 0&&`k-progress-ring--indeterminate`);let t=h.querySelector(`.k-progress-ring__bar`);t.setAttribute(`stroke-dasharray`,String(e)),t.setAttribute(`stroke-dashoffset`,String(a===void 0?e*.7:e*(1-a/100)));let n=h.querySelector(`.k-progress-ring__value`);n.textContent=f&&o?o:``,n.hidden=!n.textContent;return}h.className=p(`k-progress`,l!==`md`&&`k-progress--${l}`,u!==`brand`&&`k-progress--${u}`);let g=h.querySelector(`.k-progress__bar`);if(a===void 0?g.style.removeProperty(`--k-value`):g.style.setProperty(`--k-value`,`${a}%`),c){this.querySelector(`.k-progress-field__label`).textContent=c;let e=this.querySelector(`.k-progress-field__value`);e.textContent=f&&o?o:``,e.hidden=!e.textContent}}};B.observedAttributes=[`value`,`max`,`label`,`show-value`,`size`,`tone`,`variant`,`aria-label`];const V=/^\d{4}-\d{2}-\d{2}([T ][\d:.]+(Z|[+-]\d{2}:?\d{2})?)?$/;var H=class extends u{constructor(){super(...arguments),this.list=null,this.data=[],this.timer=null}connectedCallback(){c(()=>{this.isConnected&&(this.list||(this.data.length||(this.data=[...this.children].filter(e=>e.hasAttribute(`data-title`)).map(e=>{let t=e;return{item:{title:t.dataset.title??``,time:t.dataset.time,tone:t.dataset.tone},nodes:[...t.childNodes]}})),this.list=document.createElement(`ol`),this.list.className=`k-timeline`,this.replaceChildren(this.list)),this.render(),this.list.querySelector(`time[data-iso]`)&&(this.timer??=setInterval(()=>this.refreshTimes(),6e4)))})}disconnectedCallback(){this.timer&&clearInterval(this.timer),this.timer=null}attributeChangedCallback(){this.list&&this.render()}get items(){return this.data.map(e=>e.item)}set items(e){this.data=(e??[]).map(e=>({item:e,nodes:[]})),this.list&&this.render()}timeText(t){if(!V.test(t))return t;let n=g(t);return n?d(n,{locale:e(),digits:l(this)}):t}refreshTimes(){this.list?.querySelectorAll(`time[data-iso]`).forEach(e=>e.textContent=this.timeText(e.dateTime))}render(){let e=this.list;e.replaceChildren();for(let{item:t,nodes:n}of this.data){let i=document.createElement(`li`);i.className=`k-timeline__item`,t.tone&&t.tone!==`neutral`&&(i.dataset.tone=t.tone);let a=t.time?V.test(t.time)?`<time class="k-timeline__time" data-iso datetime="${r(t.time)}">${r(this.timeText(t.time))}</time>`:`<span class="k-timeline__time">${r(t.time)}</span>`:``;if(i.innerHTML=`<span class="k-timeline__marker" aria-hidden="true"><svg viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="3" fill="currentColor"/></svg></span><div class="k-timeline__body"><p class="k-timeline__title">${r(t.title)}</p>${a}</div>`,h(n)||t.content){let e=document.createElement(`div`);e.className=`k-timeline__content`,h(n)?e.append(...n):e.textContent=t.content,i.querySelector(`.k-timeline__body`).append(e)}e.append(i)}}};H.observedAttributes=[`digits`];const U=_(`<path d="m5 10.5 3.2 3L15 7"/>`,2.2);var W=class extends u{constructor(){super(...arguments),this.list=null,this.data=[]}connectedCallback(){c(()=>{this.isConnected&&(this.list||(!this.data.length&&!this.hasAttribute(`steps`)&&(this.data=[...this.children].filter(e=>e.tagName===`LI`).map(e=>({title:e.textContent?.trim()??``,description:e.dataset.description}))),this.list=document.createElement(`ol`),this.replaceChildren(this.list)),this.render())})}attributeChangedCallback(e,t,n){this.list&&t!==n&&(e===`steps`&&(this.data=[]),this.render())}get steps(){return this.data.length?this.data:this.parsed()}set steps(e){this.data=[...e??[]],this.list&&this.render()}get current(){return v(this,`current`,0)}set current(e){this.setAttribute(`current`,String(e))}parsed(){try{let e=JSON.parse(this.getAttribute(`steps`)??`[]`);return Array.isArray(e)?e.map(e=>typeof e==`string`?{title:e}:e):[]}catch{return[]}}render(){let e=s(),t=this.list,n=this.steps,a=this.current;t.className=p(`k-steps`,this.getAttribute(`orientation`)===`vertical`&&`k-steps--vertical`),t.setAttribute(`aria-label`,this.getAttribute(`label`)??e.stepper.label);let o=this.getAttribute(`complete-label`)??e.stepper.complete,c=this.getAttribute(`current-label`)??e.stepper.current;t.innerHTML=n.map((t,n)=>{let s=n<a?`complete`:n===a?`current`:`upcoming`;return`<li class="k-steps__step" data-status="${s}"${s===`current`?` aria-current="step"`:``}><span class="k-steps__marker" aria-hidden="true">${s===`complete`?U:i(this,n+1)}</span><span class="k-steps__title">${r(t.title)}${s===`upcoming`?``:`<span class="k-sr-only">${r(`${e.common.list}${s===`complete`?o:c}`)}</span>`}</span>${t.description?`<span class="k-steps__description">${r(t.description)}</span>`:``}</li>`}).join(``)}};W.observedAttributes=[`current`,`orientation`,`label`,`steps`,`complete-label`,`current-label`,`digits`],o(`kashi-badge`,b),o(`kashi-avatar`,w),o(`kashi-avatar-group`,T),o(`kashi-divider`,E,`contents`),o(`kashi-skeleton`,O),o(`kashi-card`,k,`block`),o(`kashi-empty-state`,P,`block`),o(`kashi-stat-card`,I,`block`),o(`kashi-alert`,R,`block`),o(`kashi-meter`,z,`block`),o(`kashi-progress`,B,`block`),o(`kashi-timeline`,H,`block`),o(`kashi-stepper`,W,`block`);export{R as KashiAlert,w as KashiAvatar,T as KashiAvatarGroup,b as KashiBadge,k as KashiCard,E as KashiDivider,P as KashiEmptyState,z as KashiMeter,B as KashiProgress,O as KashiSkeleton,I as KashiStatCard,W as KashiStepper,H as KashiTimeline,C as autoTone,S as initials};
1
+ import{d as e,i as t,j as n,l as r,m as i,n as a,o,p as s,r as c,s as l,t as u}from"./base-BqFAMlwG.js";import{t as d}from"./relative-BoBZPiB7.js";import{f,i as p,m,o as h,p as g,s as _,u as v}from"./parts-5fVaWtRe.js";var y=class extends u{constructor(){super(...arguments),this.built=!1}connectedCallback(){c(()=>{this.isConnected&&(this.built||(this.built=!0,this.build()),this.update())})}attributeChangedCallback(e,t,n){this.built&&t!==n&&this.update()}},b=class extends y{build(){let e=f(this,`icon`)[0];if(this.box=document.createElement(`span`),e){let t=document.createElement(`span`);t.className=`k-badge__icon`,t.setAttribute(`aria-hidden`,`true`),t.append(e),this.box.append(t)}this.text=document.createElement(`span`),this.text.style.display=`contents`,this.text.append(...this.childNodes),this.box.append(this.text),this.append(this.box),this.box.addEventListener(`click`,e=>{if(!e.target.closest(`.k-badge__remove`))return;let t=new CustomEvent(`kashi-remove`,{bubbles:!0,cancelable:!0,detail:{value:this.text.textContent?.trim()??``}});this.dispatchEvent(t)&&this.remove()})}update(){let e=this.getAttribute(`tone`)??`neutral`,n=this.getAttribute(`variant`)??`soft`,i=this.getAttribute(`size`)??`md`,a=t(this,`removable`);this.box.className=p(`k-badge`,e!==`neutral`&&`k-badge--${e}`,n!==`soft`&&`k-badge--${n}`,i!==`md`&&`k-badge--${i}`,t(this,`square`)&&`k-badge--square`,a&&`k-badge--removable`),this.box.dataset.tone=e,this.box.dataset.variant=n;let o=this.box.querySelector(`:scope > .k-badge__dot`);t(this,`dot`)&&!o?this.box.insertAdjacentHTML(`afterbegin`,`<span class="k-badge__dot" aria-hidden="true"></span>`):t(this,`dot`)||o?.remove();let c=this.box.querySelector(`:scope > .k-badge__remove`);if(a){let e=this.text.textContent?.trim()??``,t=this.getAttribute(`remove-label`)??(e?s().common.remove(e):s().common.removeShort);c?c.setAttribute(`aria-label`,t):this.box.insertAdjacentHTML(`beforeend`,`<button type="button" class="k-badge__remove" aria-label="${r(t)}"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="m6 6 8 8M14 6l-8 8"/></svg></button>`)}else c?.remove()}};b.observedAttributes=[`tone`,`variant`,`size`,`dot`,`square`,`removable`,`remove-label`];const x=[`brand`,`info`,`success`,`warning`,`error`],S=(e,t=2)=>e.trim().split(/\s+/).slice(0,t).map(e=>e[0]??``).join(`‌`).toUpperCase();function C(e){let t=0;for(let n of e.trim())t=t*31+n.codePointAt(0)>>>0;return x[t%x.length]}var w=class extends u{constructor(){super(...arguments),this.failed=!1}connectedCallback(){this.render()}attributeChangedCallback(e,t,n){t!==n&&this.isConnected&&(e===`src`&&(this.failed=!1),this.render())}render(){let e=this.getAttribute(`name`)??``,n=this.getAttribute(`size`)??`md`,i=this.getAttribute(`color`),a=i===`auto`?C(e):i??(t(this,`brand`)?`brand`:`neutral`),o=this.getAttribute(`status`),c=o?this.getAttribute(`status-label`)??s().avatar[o]:null,l=this.getAttribute(`src`),u=c?`${e}${s().common.list}${c}`:e,d=l&&!this.failed?`<img class="k-avatar__image" src="${r(l)}" alt="">`:`<span aria-hidden="true">${r(S(e,n===`xs`||n===`sm`?1:2))}</span>`;this.innerHTML=`<span role="img" aria-label="${r(u)}" data-tone="${a}" class="${p(`k-avatar`,n!==`md`&&`k-avatar--${n}`,t(this,`square`)&&`k-avatar--square`,a!==`neutral`&&`k-avatar--${a}`)}">${d}${o?`<span class="k-avatar__status k-avatar__status--${o}" aria-hidden="true"></span>`:``}</span>`,this.querySelector(`img`)?.addEventListener(`error`,()=>{this.failed=!0,this.render()},{once:!0})}};w.observedAttributes=[`name`,`src`,`size`,`square`,`brand`,`color`,`status`,`status-label`];var T=class extends y{build(){this.box=document.createElement(`div`),this.box.setAttribute(`role`,`group`),this.box.className=`k-avatar-group`,this.box.append(...this.childNodes),this.append(this.box)}update(){this.box.querySelector(`:scope > [data-more]`)?.remove();let e=[...this.box.children].filter(e=>e.tagName===`KASHI-AVATAR`||e.classList.contains(`k-avatar`)),t=v(this,`max`);e.forEach((e,n)=>e.hidden=!!t&&n>=t);let n=t?Math.max(0,e.length-t):0;if(!n)return;let a=this.getAttribute(`size`)??`md`,o=this.getAttribute(`more-label`)?.replace(`{n}`,i(this,n))??s().avatar.more(i(this,n));this.box.insertAdjacentHTML(`beforeend`,`<span data-more role="img" aria-label="${r(o)}" class="${p(`k-avatar`,a!==`md`&&`k-avatar--${a}`)}"><span aria-hidden="true">+${i(this,n)}</span></span>`)}};T.observedAttributes=[`max`,`size`,`more-label`];var E=class extends u{connectedCallback(){this.render()}attributeChangedCallback(){this.isConnected&&this.render()}render(){let e=this.getAttribute(`label`),n=t(this,`vertical`);this.innerHTML=`<div role="separator"${n?` aria-orientation="vertical"`:``} class="${p(`k-divider`,n&&`k-divider--vertical`)}">${e?`<span>${r(e)}</span>`:``}</div>`}};E.observedAttributes=[`label`,`vertical`];const D=e=>e===null?null:/^\d+(\.\d+)?$/.test(e)?`${e}px`:e;var O=class extends u{connectedCallback(){this.render()}attributeChangedCallback(){this.isConnected&&this.render()}render(){let e=D(this.getAttribute(`width`)),n=t(this,`circle`),i=D(this.getAttribute(`height`))??(n?e:null),a=[e&&`--k-skeleton-width: ${e}`,i&&`--k-skeleton-height: ${i}`].filter(Boolean).join(`; `),o=a?` style="${r(a)}"`:``,s=v(this,`lines`,0);this.innerHTML=s>0?`<span class="k-skeleton-group" aria-hidden="true"${o}>${`<span class="k-skeleton k-skeleton--text"></span>`.repeat(Math.min(50,s))}</span>`:`<span class="${p(`k-skeleton`,n&&`k-skeleton--circle`)}" aria-hidden="true"${o}></span>`}};O.observedAttributes=[`width`,`height`,`circle`,`lines`];var k=class extends y{build(){let e=f(this,`media`),t=f(this,`actions`),n=f(this,`footer`),r=m(this);this.box=document.createElement(`article`);for(let t of e)t.classList.add(`k-card__media`),t instanceof HTMLImageElement&&!t.style.aspectRatio&&(t.style.aspectRatio=`16 / 9`),this.box.append(t);if(this.header=document.createElement(`header`),this.header.innerHTML=`<div class="k-card__heading"></div>`,t.length){let e=document.createElement(`div`);e.className=`k-card__actions`,e.append(...t),this.header.append(e)}if(this.box.append(this.header),h(r)){let e=document.createElement(`div`);e.className=`k-card__body`,e.append(...r),this.box.append(e)}if(n.length){let e=document.createElement(`footer`);e.className=`k-card__footer`,e.append(...n),this.box.append(e)}this.append(this.box)}update(){let e=this.getAttribute(`variant`)??`outlined`,n=this.getAttribute(`padding`)??`md`;this.box.className=p(`k-card`,t(this,`flat`)&&`k-card--flat`,t(this,`interactive`)&&`k-card--interactive`,e!==`outlined`&&`k-card--${e}`,n!==`md`&&`k-card--pad-${n}`),this.box.dataset.variant=e;let i=this.getAttribute(`heading`),a=this.getAttribute(`description`),o=!!this.header.querySelector(`.k-card__actions`);this.header.className=p(`k-card__header`,o&&`k-card__header--actions`),this.header.hidden=!i&&!a&&!o;let s=Math.min(6,Math.max(1,v(this,`heading-level`,3))),c=this.header.querySelector(`.k-card__heading`);c.innerHTML=`${i?`<h${s} class="k-card__title">${r(i)}</h${s}>`:``}${a?`<p class="k-card__description">${r(a)}</p>`:``}`}};k.observedAttributes=[`heading`,`description`,`heading-level`,`variant`,`padding`,`flat`,`interactive`];const A=e=>_(e,1.5),j={noData:A(`<path d="M7.25 2.75h5.5c3.6 0 4.5.9 4.5 4.5v5.5c0 3.6-.9 4.5-4.5 4.5h-5.5c-3.6 0-4.5-.9-4.5-4.5v-5.5c0-3.6.9-4.5 4.5-4.5Z"/><path d="M2.75 10.75h3.1c.55 0 1 .3 1.25.75l.5.95c.25.45.7.75 1.25.75h2.3c.55 0 1-.3 1.25-.75l.5-.95c.25-.45.7-.75 1.25-.75h3.1"/>`),noResults:A(`<circle cx="9.1" cy="9.1" r="6.2"/><path d="m14.9 14.9 2.3 2.3M7.2 7.2l3.8 3.8M11 7.2l-3.8 3.8"/>`),error:A(`<path d="M8.33 3.9c.74-1.3 2.6-1.3 3.34 0l5.6 9.75c.74 1.3-.2 2.85-1.67 2.85H4.4c-1.48 0-2.41-1.56-1.67-2.85Z"/><path d="M10 7.9v3.1M10 13.6v.01"/>`),offline:A(`<path d="M2.75 7.6a10.5 10.5 0 0 1 14.5 0M5.2 10.3a7 7 0 0 1 9.6 0M7.7 12.95a3.5 3.5 0 0 1 4.6 0M10 15.75v.01"/><path d="m3 3 14 14"/>`),noAccess:A(`<path d="M7.25 8.25h5.5c2.6 0 3.25.65 3.25 3.25v2.75c0 2.6-.65 3.25-3.25 3.25h-5.5C4.65 17.5 4 16.85 4 14.25V11.5c0-2.6.65-3.25 3.25-3.25Z"/><path d="M6.9 8.3V6.4a3.1 3.1 0 0 1 6.2 0v1.9M10 11.6v2.2"/>`),done:A(`<circle cx="10" cy="10" r="7.25"/><path d="m6.75 10.1 2.2 2.2 4.3-4.5"/>`)},M=[`noData`,`noResults`,`error`,`offline`,`noAccess`,`done`],N=e=>{if(!e)return null;let t=e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase());return M.includes(t)?t:null};var P=class extends y{constructor(){super(...arguments),this.customIcon=null,this.actions=null}build(){this.customIcon=f(this,`icon`)[0]??null;let e=f(this,`actions`);this.box=document.createElement(`div`),this.box.innerHTML=`<span class="k-empty__icon" aria-hidden="true"></span><p class="k-empty__title"></p><p class="k-empty__description"></p>`,this.customIcon&&this.box.firstElementChild.append(this.customIcon);let t=m(this);(e.length||h(t))&&(this.actions=document.createElement(`div`),this.actions.className=`k-empty__actions`,this.actions.append(...e,...h(t)?t:[]),this.box.append(this.actions)),this.replaceChildren(this.box)}update(){let e=N(this.getAttribute(`preset`)),n=this.getAttribute(`size`)??`md`,r=e?s().empty[e]:void 0;this.box.className=p(`k-empty`,n!==`md`&&`k-empty--${n}`,t(this,`bordered`)&&`k-empty--bordered`),e?this.box.dataset.preset=e:delete this.box.dataset.preset,e===`error`||e===`offline`?this.box.setAttribute(`role`,`status`):this.box.removeAttribute(`role`);let i=this.box.querySelector(`.k-empty__icon`);this.customIcon||(i.innerHTML=e?j[e]:``),i.hidden=!i.firstChild;let a=this.getAttribute(`heading`)??r?.[0]??``,o=this.getAttribute(`description`)??r?.[1]??``,c=this.box.querySelector(`.k-empty__title`),l=this.box.querySelector(`.k-empty__description`);c.textContent=a,c.hidden=!a,l.textContent=o,l.hidden=!o}};P.observedAttributes=[`preset`,`heading`,`description`,`size`,`bordered`];const F=e=>_(e?`<path d="M10 15V5m0 0-4 4m4-4 4 4"/>`:`<path d="M10 5v10m0 0-4-4m4 4 4-4"/>`,1.8);var I=class extends y{build(){let e=f(this,`icon`)[0],t=m(this);if(this.box=document.createElement(`div`),this.box.className=`k-stat`,this.box.innerHTML=`<div class="k-stat__head"><p class="k-stat__label"></p></div><p class="k-stat__value"><span></span><span class="k-stat__unit"></span></p><div class="k-stat__foot"></div>`,e){let t=document.createElement(`span`);t.className=`k-stat__icon`,t.setAttribute(`aria-hidden`,`true`),t.append(e),this.box.firstElementChild.prepend(t)}if(h(t)){let e=document.createElement(`div`);e.className=`k-stat__chart`,e.append(...t),this.box.append(e)}this.replaceChildren(this.box)}update(){let e=s(),n=v(this,`change`);this.box.querySelector(`.k-stat__label`).textContent=this.getAttribute(`label`)??``;let a=this.getAttribute(`value`)??``;this.box.querySelector(`.k-stat__value > span`).textContent=/^-?[\d.,]+$/.test(a)?i(this,a):a;let o=this.box.querySelector(`.k-stat__unit`);o.textContent=this.getAttribute(`unit`)??``,o.hidden=!o.textContent,t(this,`loading`)?this.box.setAttribute(`aria-busy`,`true`):this.box.removeAttribute(`aria-busy`);let c=n===void 0?null:n>0?`up`:n<0?`down`:`flat`,l=c===`flat`?`flat`:c===`up`===t(this,`invert-trend`)?`down`:`up`,u=this.getAttribute(`up-label`)??e.stat.up,d=this.getAttribute(`down-label`)??e.stat.down,f=this.getAttribute(`flat-label`)??e.stat.flat,p=n===void 0?``:e.common.percent(i(this,Math.abs(Math.round(n*10)/10)).replace(`.`,e.common.decimal)),m=this.getAttribute(`caption`),h=this.box.querySelector(`.k-stat__foot`);h.hidden=!c&&!m,h.innerHTML=`${c?`<span class="k-trend k-trend--${l}">${c===`flat`?``:F(c===`up`)}<span aria-hidden="true">${r(c===`flat`?f:p)}</span><span class="k-sr-only">${r(c===`flat`?f:`${p} ${c===`up`?u:d}`)}</span></span>`:``}${m?`<span>${r(m)}</span>`:``}`}};I.observedAttributes=[`label`,`value`,`unit`,`change`,`invert-trend`,`caption`,`loading`,`up-label`,`down-label`,`flat-label`];const L={neutral:a.info,brand:a.info,info:a.info,success:a.success,warning:a.warning,error:a.error};var R=class extends y{constructor(){super(...arguments),this.customIcon=null}build(){this.customIcon=f(this,`icon`)[0]??null;let e=f(this,`actions`),t=m(this);this.box=document.createElement(`div`),this.box.innerHTML=`<span class="k-alert__icon" aria-hidden="true"></span><div class="k-alert__content"><p class="k-alert__title"></p></div>`;let n=this.box.querySelector(`.k-alert__content`);if(h(t)){let e=document.createElement(`div`);e.className=`k-alert__description`,e.append(...t),n.append(e)}if(e.length){let t=document.createElement(`div`);t.className=`k-alert__actions`,t.append(...e),n.append(t)}this.customIcon&&this.box.firstElementChild.append(this.customIcon),this.replaceChildren(this.box),this.box.addEventListener(`click`,e=>{e.target.closest(`.k-alert__close`)&&this.close()})}update(){let e=this.getAttribute(`tone`)??`neutral`;this.box.className=p(`k-alert`,e!==`neutral`&&`k-alert--${e}`,t(this,`tinted`)&&`k-alert--tinted`,this.getAttribute(`layout`)===`banner`&&`k-alert--banner`,this.getAttribute(`size`)===`sm`&&`k-alert--sm`),this.box.dataset.tone=e,this.box.setAttribute(`role`,e===`error`||e===`warning`?`alert`:`status`);let n=this.box.querySelector(`.k-alert__icon`);n.hidden=this.getAttribute(`icon`)===`false`,this.customIcon||(n.innerHTML=L[e]??a.info);let r=this.box.querySelector(`.k-alert__title`);r.textContent=this.getAttribute(`heading`)??``,r.hidden=!r.textContent;let i=this.box.querySelector(`:scope > .k-alert__close`);t(this,`dismissible`)?(i||=(this.box.insertAdjacentHTML(`beforeend`,`<button type="button" class="k-btn k-btn--tertiary k-btn--icon k-btn--sm k-alert__close">${a.close}</button>`),this.box.querySelector(`:scope > .k-alert__close`)),i.setAttribute(`aria-label`,this.getAttribute(`close-label`)??s().alert.close)):i?.remove()}close(){let e=new CustomEvent(`kashi-close`,{bubbles:!0,cancelable:!0,detail:{}});this.dispatchEvent(e)&&(this.hidden=!0)}};R.observedAttributes=[`tone`,`heading`,`tinted`,`layout`,`size`,`dismissible`,`close-label`,`icon`];var z=class extends u{constructor(){super(...arguments),this.box=null}connectedCallback(){this.box||(this.box=document.createElement(`div`),this.box.className=`k-meter`,this.box.innerHTML=`<div class="k-meter__head"><span class="k-meter__label"></span><span class="k-meter__value"></span></div><div class="k-meter__track" role="meter" aria-valuemin="0"><span class="k-meter__fill"></span><span class="k-meter__mark" aria-hidden="true"></span></div><p class="k-meter__status" aria-hidden="true"></p>`,this.replaceChildren(this.box)),this.update()}attributeChangedCallback(){this.box&&this.update()}update(){let e=s(),t=v(this,`max`,100)||100,a=v(this,`warning`,t*.8),o=v(this,`critical`,t*.95),c=Math.min(t,Math.max(0,v(this,`value`,0))),u=c>=o?`critical`:c>=a?`warning`:`ok`,d=Math.round(c/t*100),f=this.getAttribute(`${u}-label`)??e.meter[u],p=this.getAttribute(`unit`),m=e=>`${n(Math.round(e*100)/100,{digits:l(this)})}${p?` ${p}`:``}`,h=this.getAttribute(`of`),g=this.getAttribute(`label`)??``,y=this.box;y.dataset.status=u,y.querySelector(`.k-meter__label`).textContent=g,y.querySelector(`.k-meter__value`).innerHTML=`${r(m(c))} <span>${r(h==null?s().common.of(``,m(t)).trim():`${h} ${m(t)}`)}</span>`;let b=y.querySelector(`.k-meter__track`);b.setAttribute(`aria-valuenow`,String(c)),b.setAttribute(`aria-valuemax`,String(t)),b.setAttribute(`aria-valuetext`,`${h?`${m(c)} ${h} ${m(t)}`:e.common.of(m(c),m(t))}${e.common.list}${e.common.percent(i(this,d))}${e.common.list}${f}`),g&&b.setAttribute(`aria-label`,g),y.querySelector(`.k-meter__fill`).style.inlineSize=`${d}%`,y.querySelector(`.k-meter__mark`).style.insetInlineStart=`${a/t*100}%`,y.querySelector(`.k-meter__status`).innerHTML=`${_(`<path d="${u===`ok`?`m5 10.5 3.2 3L15 7`:`M10 3 2.5 16.5h15ZM10 8v4M10 14.5h.01`}"/>`,1.8)}${r(f)} · ${r(e.common.percent(i(this,d)))}`}};z.observedAttributes=[`label`,`value`,`max`,`warning`,`critical`,`unit`,`of`,`ok-label`,`warning-label`,`critical-label`,`digits`];var B=class extends u{constructor(){super(...arguments),this.kind=``}connectedCallback(){this.update()}attributeChangedCallback(){this.isConnected&&this.update()}update(){let e=s(),n=v(this,`max`,100)||100,r=v(this,`value`),a=r===void 0?void 0:Math.max(0,Math.min(100,r/n*100)),o=a===void 0?void 0:e.common.percent(i(this,Math.round(a))),c=this.getAttribute(`label`),l=this.getAttribute(`size`)??`md`,u=this.getAttribute(`tone`)??`brand`,d=this.getAttribute(`variant`)===`circular`,f=t(this,`show-value`),m=`${d}-${!!c}`;m!==this.kind&&(this.kind=m,this.innerHTML=d?`<div role="progressbar" aria-valuemin="0"><svg viewBox="0 0 40 40" aria-hidden="true"><circle class="k-progress-ring__track" cx="20" cy="20" r="16"/><circle class="k-progress-ring__bar" cx="20" cy="20" r="16"/></svg><span class="k-progress-ring__value" aria-hidden="true"></span></div>`:`${c?`<div class="k-progress-field"><div class="k-progress-field__head" aria-hidden="true"><span class="k-progress-field__label"></span><span class="k-progress-field__value"></span></div>`:``}<div role="progressbar" aria-valuemin="0"><div class="k-progress__bar"></div></div>${c?`</div>`:``}`);let h=this.querySelector(`[role="progressbar"]`);h.setAttribute(`aria-valuemax`,String(n));for(let[e,t]of[[`aria-valuenow`,r===void 0?null:String(r)],[`aria-valuetext`,o??null],[`aria-label`,this.getAttribute(`aria-label`)??c]])t===null?h.removeAttribute(e):h.setAttribute(e,t);if(d){let e=2*Math.PI*16;h.className=p(`k-progress-ring`,l!==`md`&&`k-progress-ring--${l}`,u!==`brand`&&`k-progress--${u}`,a===void 0&&`k-progress-ring--indeterminate`);let t=h.querySelector(`.k-progress-ring__bar`);t.setAttribute(`stroke-dasharray`,String(e)),t.setAttribute(`stroke-dashoffset`,String(a===void 0?e*.7:e*(1-a/100)));let n=h.querySelector(`.k-progress-ring__value`);n.textContent=f&&o?o:``,n.hidden=!n.textContent;return}h.className=p(`k-progress`,l!==`md`&&`k-progress--${l}`,u!==`brand`&&`k-progress--${u}`);let g=h.querySelector(`.k-progress__bar`);if(a===void 0?g.style.removeProperty(`--k-value`):g.style.setProperty(`--k-value`,`${a}%`),c){this.querySelector(`.k-progress-field__label`).textContent=c;let e=this.querySelector(`.k-progress-field__value`);e.textContent=f&&o?o:``,e.hidden=!e.textContent}}};B.observedAttributes=[`value`,`max`,`label`,`show-value`,`size`,`tone`,`variant`,`aria-label`];const V=/^\d{4}-\d{2}-\d{2}([T ][\d:.]+(Z|[+-]\d{2}:?\d{2})?)?$/;var H=class extends u{constructor(){super(...arguments),this.list=null,this.data=[],this.timer=null}connectedCallback(){c(()=>{this.isConnected&&(this.list||(this.data.length||(this.data=[...this.children].filter(e=>e.hasAttribute(`data-title`)).map(e=>{let t=e;return{item:{title:t.dataset.title??``,time:t.dataset.time,tone:t.dataset.tone},nodes:[...t.childNodes]}})),this.list=document.createElement(`ol`),this.list.className=`k-timeline`,this.replaceChildren(this.list)),this.render(),this.list.querySelector(`time[data-iso]`)&&(this.timer??=setInterval(()=>this.refreshTimes(),6e4)))})}disconnectedCallback(){this.timer&&clearInterval(this.timer),this.timer=null}attributeChangedCallback(){this.list&&this.render()}get items(){return this.data.map(e=>e.item)}set items(e){this.data=(e??[]).map(e=>({item:e,nodes:[]})),this.list&&this.render()}timeText(t){if(!V.test(t))return t;let n=g(t);return n?d(n,{locale:e(),digits:l(this)}):t}refreshTimes(){this.list?.querySelectorAll(`time[data-iso]`).forEach(e=>e.textContent=this.timeText(e.dateTime))}render(){let e=this.list;e.replaceChildren();for(let{item:t,nodes:n}of this.data){let i=document.createElement(`li`);i.className=`k-timeline__item`,t.tone&&t.tone!==`neutral`&&(i.dataset.tone=t.tone);let a=t.time?V.test(t.time)?`<time class="k-timeline__time" data-iso datetime="${r(t.time)}">${r(this.timeText(t.time))}</time>`:`<span class="k-timeline__time">${r(t.time)}</span>`:``;if(i.innerHTML=`<span class="k-timeline__marker" aria-hidden="true"><svg viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="3" fill="currentColor"/></svg></span><div class="k-timeline__body"><p class="k-timeline__title">${r(t.title)}</p>${a}</div>`,h(n)||t.content){let e=document.createElement(`div`);e.className=`k-timeline__content`,h(n)?e.append(...n):e.textContent=t.content,i.querySelector(`.k-timeline__body`).append(e)}e.append(i)}}};H.observedAttributes=[`digits`];const U=_(`<path d="m5 10.5 3.2 3L15 7"/>`,2.2);var W=class extends u{constructor(){super(...arguments),this.list=null,this.data=[]}connectedCallback(){c(()=>{this.isConnected&&(this.list||(!this.data.length&&!this.hasAttribute(`steps`)&&(this.data=[...this.children].filter(e=>e.tagName===`LI`).map(e=>({title:e.textContent?.trim()??``,description:e.dataset.description}))),this.list=document.createElement(`ol`),this.replaceChildren(this.list)),this.render())})}attributeChangedCallback(e,t,n){this.list&&t!==n&&(e===`steps`&&(this.data=[]),this.render())}get steps(){return this.data.length?this.data:this.parsed()}set steps(e){this.data=[...e??[]],this.list&&this.render()}get current(){return v(this,`current`,0)}set current(e){this.setAttribute(`current`,String(e))}parsed(){try{let e=JSON.parse(this.getAttribute(`steps`)??`[]`);return Array.isArray(e)?e.map(e=>typeof e==`string`?{title:e}:e):[]}catch{return[]}}render(){let e=s(),t=this.list,n=this.steps,a=this.current;t.className=p(`k-steps`,this.getAttribute(`orientation`)===`vertical`&&`k-steps--vertical`),t.setAttribute(`aria-label`,this.getAttribute(`label`)??e.stepper.label);let o=this.getAttribute(`complete-label`)??e.stepper.complete,c=this.getAttribute(`current-label`)??e.stepper.current;t.innerHTML=n.map((t,n)=>{let s=n<a?`complete`:n===a?`current`:`upcoming`;return`<li class="k-steps__step" data-status="${s}"${s===`current`?` aria-current="step"`:``}><span class="k-steps__marker" aria-hidden="true">${s===`complete`?U:i(this,n+1)}</span><span class="k-steps__title">${r(t.title)}${s===`upcoming`?``:`<span class="k-sr-only">${r(`${e.common.list}${s===`complete`?o:c}`)}</span>`}</span>${t.description?`<span class="k-steps__description">${r(t.description)}</span>`:``}</li>`}).join(``)}};W.observedAttributes=[`current`,`orientation`,`label`,`steps`,`complete-label`,`current-label`,`digits`],o(`kashi-badge`,b),o(`kashi-avatar`,w),o(`kashi-avatar-group`,T),o(`kashi-divider`,E,`contents`),o(`kashi-skeleton`,O),o(`kashi-card`,k,`block`),o(`kashi-empty-state`,P,`block`),o(`kashi-stat-card`,I,`block`),o(`kashi-alert`,R,`block`),o(`kashi-meter`,z,`block`),o(`kashi-progress`,B,`block`),o(`kashi-timeline`,H,`block`),o(`kashi-stepper`,W,`block`);export{R as KashiAlert,w as KashiAvatar,T as KashiAvatarGroup,b as KashiBadge,k as KashiCard,E as KashiDivider,P as KashiEmptyState,z as KashiMeter,B as KashiProgress,O as KashiSkeleton,I as KashiStatCard,W as KashiStepper,H as KashiTimeline,C as autoTone,S as initials};
@@ -1 +1 @@
1
- import{M as e,N as t,P as n,_ as r,c as i,i as a,j as o,l as s,m as c,o as l,p as u,s as d,t as f,u as p,y as m}from"./base-D4tCOysh.js";import{n as h}from"./text-C6fzEBBh.js";function g(e,t,n){if(e.querySelectorAll(`:scope > input[type=hidden][data-kashi-value]`).forEach(e=>e.remove()),t)for(let r of n){let n=document.createElement(`input`);n.type=`hidden`,n.name=t,n.value=r,n.dataset.kashiValue=``,e.append(n)}}var _=class extends f{constructor(){super(...arguments),this.tags=[],this.localError=null,this.rendered=!1,this.valueSet=!1,this.key=m(`kashi-tags`)}connectedCallback(){!this.rendered&&!this.valueSet&&(this.tags=this.parse(this.getAttribute(`value`))),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.value=this.parse(n):this.render())}parse(e){return(e??``).split(/[,،]/).map(e=>e.trim()).filter(Boolean)}get value(){return[...this.tags]}set value(e){this.valueSet=!0,this.tags=Array.isArray(e)?[...e]:this.parse(e),this.rendered&&this.paint()}focus(e){this.input?.focus(e)}render(){let e=this.key,t=this.getAttribute(`aria-label`),n=this.hasAttribute(`label`)?this.getAttribute(`label`):t?null:u().tagInput.label,r=`<div class="k-tag-input"><input id="${e}" class="k-tag-input__control"${this.hasAttribute(`disabled`)?` disabled`:``}${!n&&t?` aria-label="${s(t)}"`:``}></div><span class="k-sr-only" aria-live="polite"></span>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,p({id:e,label:n,control:r})),this.input=this.querySelector(`.k-tag-input__control`),this.querySelector(`.k-tag-input`).addEventListener(`click`,e=>{let t=e.target.closest(`.k-badge__remove`);t?this.removeAt(Number(t.dataset.i)):this.input.focus()}),this.input.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===`,`||e.key===`،`)&&this.input.value.trim()?(e.preventDefault(),this.add([this.input.value])):e.key===`Backspace`&&!this.input.value&&this.tags.length&&this.removeAt(this.tags.length-1)}),this.input.addEventListener(`input`,()=>{this.localError=null;let e=this.input.value.split(/[,،\n\t]/);if(e.length>1){let t=e.pop()??``;this.add(e),t&&!this.localError&&(this.input.value=t)}else this.paintMessages()}),this.input.addEventListener(`blur`,()=>this.input.value.trim()&&this.add([this.input.value])),this.rendered=!0,this.paint()}add(e){let t=Number(this.getAttribute(`max`))||1/0,n=a(this,`allow-duplicates`),r=[...this.tags],i=``;for(let a of e){let e=h(a).trim();if(!e)continue;let o=r.length>=t?u().common.max(c(this,t)):!n&&r.includes(e)?u().tagInput.duplicate:this.validate?.(e);if(o){this.localError=o,this.commit(r,i),this.input.value=e;return}r=[...r,e],i=u().common.added(e)}this.localError=null,this.input.value=``,this.commit(r,i)}removeAt(e){let t=this.tags[e];this.commit(this.tags.filter((t,n)=>n!==e),u().common.removed(t)),this.input.focus()}commit(e,t){let n=e.join(`\0`)!==this.tags.join(`\0`);this.tags=e,this.paint(),t&&(this.querySelector(`.k-field > .k-sr-only`).textContent=t),n&&i(this,`kashi-change`,{value:[...e]})}paint(){this.querySelector(`.k-tag-input`).querySelectorAll(`.k-badge`).forEach(e=>e.remove());let e=this.getAttribute(`tone`)??`brand`,t=this.hasAttribute(`disabled`),n=this.tags.map((n,r)=>`<span class="k-badge${e===`neutral`?``:` k-badge--${s(e)}`}${t?``:` k-badge--removable`}">${s(n)}${t?``:`<button type="button" class="k-badge__remove" data-i="${r}" aria-label="${s(u().common.remove(n))}"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="m6 6 8 8M14 6l-8 8"/></svg></button>`}</span>`).join(``);this.input.insertAdjacentHTML(`beforebegin`,n),this.input.placeholder=this.tags.length?``:this.getAttribute(`placeholder`)??``,this.paintMessages(),g(this,this.getAttribute(`name`),this.tags)}paintMessages(){let e=this.getAttribute(`error`)||this.localError;this.querySelector(`.k-tag-input`).toggleAttribute(`data-invalid`,!!e),r(this.querySelector(`:scope > .k-field`),this.input,this.key,e,this.getAttribute(`hint`))}};_.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`disabled`,`name`,`value`,`max`,`tone`,`allow-duplicates`,`aria-label`];var v=class extends f{constructor(){super(...arguments),this.current=null,this.rendered=!1,this.valueSet=!1,this.key=m(`kashi-num`)}connectedCallback(){!this.rendered&&!this.valueSet&&(this.current=this.num(this.getAttribute(`value`))??null),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.value=n===null||n===``?null:Number(n):this.render())}get value(){return this.current}set value(e){this.valueSet=!0,this.current=e==null||Number.isNaN(Number(e))?null:Number(e),this.rendered&&this.paint()}focus(e){this.input?.focus(e)}num(e){return e===null||e===``||Number.isNaN(Number(e))?void 0:Number(e)}get min(){return this.num(this.getAttribute(`min`))}get max(){return this.num(this.getAttribute(`max`))}clamp(e){return Math.min(this.max??1/0,Math.max(this.min??-1/0,e))}show(e){if(e===null)return``;let t=this.hasAttribute(`thousands`)?o(e,{digits:`latin`}):String(e);return d(this)===`latin`?t:n(t).replace(/,/g,`٬`)}render(){let t=this.key,n=this.getAttribute(`aria-label`),r=this.hasAttribute(`label`)?this.getAttribute(`label`):n?null:u().numberInput.label,i=this.hasAttribute(`disabled`),a=this.getAttribute(`unit`),o=`<div class="k-number"><div class="k-input"${i?` data-state="disabled"`:``}><button type="button" class="k-number__step" data-step="-1" tabindex="-1" aria-label="${s(u().numberInput.decrement)}"${i?` disabled`:``}><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><path d="M5 10h10"/></svg></button><input id="${t}" class="k-input__control" type="text" inputmode="decimal" role="spinbutton" dir="ltr"${i?` disabled`:``}${!r&&n?` aria-label="${s(n)}"`:``}>${a?`<span class="k-input__addon">${s(a)}</span>`:``}<button type="button" class="k-number__step" data-step="1" tabindex="-1" aria-label="${s(u().numberInput.increment)}"${i?` disabled`:``}><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><path d="M10 5v10M5 10h10"/></svg></button></div></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,p({id:t,label:r,control:o})),this.input=this.querySelector(`input.k-input__control`),this.querySelectorAll(`.k-number__step`).forEach(e=>e.addEventListener(`click`,()=>this.bump(Number(e.dataset.step)))),this.input.addEventListener(`input`,()=>{let t=this.input.value,n=e(t);this.set(n?(/^\s*[-−]/.test(t)?-1:1)*Number(n):null,!1)}),this.input.addEventListener(`blur`,()=>{this.current!==null&&this.current!==this.clamp(this.current)?this.set(this.clamp(this.current)):this.paint()}),this.input.addEventListener(`keydown`,e=>{let t={ArrowUp:()=>this.bump(1),ArrowDown:()=>this.bump(-1),PageUp:()=>this.bump(10),PageDown:()=>this.bump(-10),Home:()=>this.min!==void 0&&this.set(this.min),End:()=>this.max!==void 0&&this.set(this.max)};t[e.key]&&(e.preventDefault(),t[e.key]())}),this.rendered=!0,this.paint()}bump(e){let t=this.num(this.getAttribute(`step`))??1;this.set(this.clamp((this.current??this.min??0)+e*t))}set(e,t=!0){let n=e!==this.current;this.current=e,t?this.paint():this.paintState(),n&&i(this,`kashi-change`,{value:e})}paint(){let e=this.show(this.current);this.input.value!==e&&(this.input.value=e),this.paintState()}paintState(){let e=this.input,t=this.current;for(let[n,r]of[[`aria-valuenow`,t],[`aria-valuemin`,this.min],[`aria-valuemax`,this.max]])r==null?e.removeAttribute(n):e.setAttribute(n,String(r));t===null?e.removeAttribute(`aria-valuetext`):e.setAttribute(`aria-valuetext`,this.show(t));let n=this.hasAttribute(`disabled`),[i,a]=this.querySelectorAll(`.k-number__step`);i.disabled=n||this.min!==void 0&&(t??0)<=this.min,a.disabled=n||this.max!==void 0&&(t??0)>=this.max,r(this.querySelector(`:scope > .k-field`),e,this.key,this.getAttribute(`error`),this.getAttribute(`hint`)),g(this,this.getAttribute(`name`),[t===null?``:String(t)])}};v.observedAttributes=[`label`,`hint`,`error`,`value`,`min`,`max`,`step`,`thousands`,`digits`,`unit`,`disabled`,`name`,`aria-label`];const y=`<svg viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="M12 2.8l2.8 5.9 6.4.8-4.7 4.4 1.2 6.3L12 17.1l-5.7 3.1 1.2-6.3L2.8 9.5l6.4-.8z"/><path class="k-rating__half" fill="none" d="M12 2.8v14.3l-5.7 3.1 1.2-6.3L2.8 9.5l6.4-.8z"/></svg>`;var b=class extends f{constructor(){super(...arguments),this.current=0,this.valueSet=!1,this.key=m(`kashi-rate`)}connectedCallback(){this.valueSet||(this.current=Number(this.getAttribute(`value`))||0),this.render()}attributeChangedCallback(e,t,n){t!==n&&this.isConnected&&(e===`value`&&(this.current=Number(n)||0),this.render())}get value(){return this.current}set value(e){this.valueSet=!0,this.current=Number(e)||0,this.isConnected&&this.render()}render(){let e=Number(this.getAttribute(`max`))||5,t=this.getAttribute(`label`)??u().rating.label,n=e=>c(this,e).replace(`.`,u().common.decimal),r=this.getAttribute(`size`),a=`k-rating${r===`sm`||r===`lg`?` k-rating--${r}`:``}`,o=this.current,l=Array.from({length:e},(e,t)=>t+1),d=this.hasAttribute(`show-value`)?`<span class="k-rating__value" aria-hidden="true">${n(o)}</span>`:``;if(this.hasAttribute(`readonly`)){this.innerHTML=`<span class="${a}" data-readonly="" role="img" aria-label="${s(`${t}: ${u().common.of(n(o),n(e))}`)}">${l.map(e=>`<span class="k-rating__star"${e<=Math.floor(o)?` data-filled=""`:``}${e===Math.ceil(o)&&o%1>=.25?` data-half=""`:``}>${y}</span>`).join(``)}${d}</span>`;return}let f=this.getAttribute(`name`)??this.key,p=this.hasAttribute(`disabled`);this.innerHTML=`<fieldset class="${a}"><legend class="k-sr-only">${s(t)}</legend>${l.map(t=>`<label class="k-rating__star"${t<=o?` data-filled=""`:``}><input type="radio" class="k-sr-only" name="${s(f)}" value="${t}"${o===t?` checked`:``}${p?` disabled`:``} aria-label="${s(u().common.of(n(t),n(e)))}">${y}</label>`).join(``)}${d}</fieldset>`;let m=this.querySelector(`fieldset`),h=e=>m.querySelectorAll(`.k-rating__star`).forEach((t,n)=>t.toggleAttribute(`data-filled`,n+1<=e));m.addEventListener(`change`,e=>{this.current=Number(e.target.value),h(this.current),i(this,`kashi-change`,{value:this.current})}),m.addEventListener(`pointerover`,e=>{let t=e.target.closest(`.k-rating__star`);t&&!p&&h([...m.querySelectorAll(`.k-rating__star`)].indexOf(t)+1)}),m.addEventListener(`pointerleave`,()=>h(this.current))}};b.observedAttributes=[`value`,`max`,`readonly`,`show-value`,`size`,`label`,`name`,`disabled`];function x(e,t,n=1){let r=[1],i=Math.max(2,e-n),a=Math.min(t-1,e+n);i>2&&r.push(i===3?2:null);for(let e=i;e<=a;e++)r.push(e);return a<t-1&&r.push(a===t-2?t-1:null),t>1&&r.push(t),r}const S=e=>`<svg data-k-mirror="" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${e}"/></svg>`;var C=class extends f{connectedCallback(){this.render()}attributeChangedCallback(e,t,n){t!==n&&this.isConnected&&this.render()}get page(){return Math.max(1,Number(this.getAttribute(`page`))||1)}set page(e){this.setAttribute(`page`,String(e))}get total(){return Math.max(1,Number(this.getAttribute(`total`))||1)}render(){let e=Math.min(this.page,this.total),t=this.total,r=e=>d(this)===`latin`?String(e):n(e),a=this.getAttribute(`href`),o=this.contains(document.activeElement)?document.activeElement.dataset.to:null,c=(e,t,n,{current:r=!1,disabled:i=!1,aria:o=``}={})=>a&&!i?`<a class="${n}" href="${s(a.replace(`{page}`,String(e)))}" data-to="${e}"${r?` aria-current="page"`:``}${o?` aria-label="${s(o)}"`:``}>${t}</a>`:`<button type="button" class="${n}" data-to="${e}"${i?` disabled`:``}${r?` aria-current="page"`:``}${o?` aria-label="${s(o)}"`:``}>${t}</button>`,l=this.getAttribute(`summary`);this.innerHTML=`<nav class="k-pagination" aria-label="${s(this.getAttribute(`label`)??u().pagination.nav)}">${c(e-1,`${S(`m12 5-5 5 5 5`)}${s(u().common.prev)}`,`k-btn k-btn--secondary k-btn--sm`,{disabled:e<=1})}${l?`<span class="k-pagination__summary">${s(l)}</span>`:``}<ul class="k-pagination__pages" role="list">${x(e,t,Number(this.getAttribute(`siblings`)??1)).map(t=>`<li>${t===null?`<span class="k-pagination__ellipsis" aria-hidden="true">…</span>`:c(t,r(t),`k-pagination__page`,{current:t===e,aria:u().pagination.page(r(t))})}</li>`).join(``)}</ul>${c(e+1,`${s(u().common.next)}${S(`m8 5 5 5-5 5`)}`,`k-btn k-btn--secondary k-btn--sm`,{disabled:e>=t})}</nav>`,this.querySelector(`nav`).addEventListener(`click`,e=>{let t=e.target.closest(`button[data-to]`);if(!t||t.disabled)return;let n=Number(t.dataset.to);this.setAttribute(`page`,String(n)),i(this,`kashi-change`,{page:n}),this.querySelector(`.k-pagination__page[data-to="${n}"]`)?.focus()}),o&&this.querySelector(`[data-to="${o}"]`)?.focus()}};C.observedAttributes=[`page`,`total`,`siblings`,`href`,`digits`,`label`,`summary`];const w=e=>{let n=t(e).replace(/[٬,\s]/g,``).replace(`٫`,`.`).replace(`−`,`-`).match(/-?\d+(\.\d+)?/);return n?Number(n[0]):NaN};l(`kashi-tag-input`,_,`block`),l(`kashi-number-input`,v,`block`),l(`kashi-rating`,b),l(`kashi-pagination`,C,`block`);export{v as KashiNumberInput,C as KashiPagination,b as KashiRating,_ as KashiTagInput,w as cellNumber,x as pageRange};
1
+ import{M as e,N as t,P as n,_ as r,c as i,i as a,j as o,l as s,m as c,o as l,p as u,s as d,t as f,u as p,y as m}from"./base-BqFAMlwG.js";import{n as h}from"./text-DFyW6cuq.js";function g(e,t,n){if(e.querySelectorAll(`:scope > input[type=hidden][data-kashi-value]`).forEach(e=>e.remove()),t)for(let r of n){let n=document.createElement(`input`);n.type=`hidden`,n.name=t,n.value=r,n.dataset.kashiValue=``,e.append(n)}}var _=class extends f{constructor(){super(...arguments),this.tags=[],this.localError=null,this.rendered=!1,this.valueSet=!1,this.key=m(`kashi-tags`)}connectedCallback(){!this.rendered&&!this.valueSet&&(this.tags=this.parse(this.getAttribute(`value`))),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.value=this.parse(n):this.render())}parse(e){return(e??``).split(/[,،]/).map(e=>e.trim()).filter(Boolean)}get value(){return[...this.tags]}set value(e){this.valueSet=!0,this.tags=Array.isArray(e)?[...e]:this.parse(e),this.rendered&&this.paint()}focus(e){this.input?.focus(e)}render(){let e=this.key,t=this.getAttribute(`aria-label`),n=this.hasAttribute(`label`)?this.getAttribute(`label`):t?null:u().tagInput.label,r=`<div class="k-tag-input"><input id="${e}" class="k-tag-input__control"${this.hasAttribute(`disabled`)?` disabled`:``}${!n&&t?` aria-label="${s(t)}"`:``}></div><span class="k-sr-only" aria-live="polite"></span>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,p({id:e,label:n,control:r})),this.input=this.querySelector(`.k-tag-input__control`),this.querySelector(`.k-tag-input`).addEventListener(`click`,e=>{let t=e.target.closest(`.k-badge__remove`);t?this.removeAt(Number(t.dataset.i)):this.input.focus()}),this.input.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===`,`||e.key===`،`)&&this.input.value.trim()?(e.preventDefault(),this.add([this.input.value])):e.key===`Backspace`&&!this.input.value&&this.tags.length&&this.removeAt(this.tags.length-1)}),this.input.addEventListener(`input`,()=>{this.localError=null;let e=this.input.value.split(/[,،\n\t]/);if(e.length>1){let t=e.pop()??``;this.add(e),t&&!this.localError&&(this.input.value=t)}else this.paintMessages()}),this.input.addEventListener(`blur`,()=>this.input.value.trim()&&this.add([this.input.value])),this.rendered=!0,this.paint()}add(e){let t=Number(this.getAttribute(`max`))||1/0,n=a(this,`allow-duplicates`),r=[...this.tags],i=``;for(let a of e){let e=h(a).trim();if(!e)continue;let o=r.length>=t?u().common.max(c(this,t)):!n&&r.includes(e)?u().tagInput.duplicate:this.validate?.(e);if(o){this.localError=o,this.commit(r,i),this.input.value=e;return}r=[...r,e],i=u().common.added(e)}this.localError=null,this.input.value=``,this.commit(r,i)}removeAt(e){let t=this.tags[e];this.commit(this.tags.filter((t,n)=>n!==e),u().common.removed(t)),this.input.focus()}commit(e,t){let n=e.join(`\0`)!==this.tags.join(`\0`);this.tags=e,this.paint(),t&&(this.querySelector(`.k-field > .k-sr-only`).textContent=t),n&&i(this,`kashi-change`,{value:[...e]})}paint(){this.querySelector(`.k-tag-input`).querySelectorAll(`.k-badge`).forEach(e=>e.remove());let e=this.getAttribute(`tone`)??`brand`,t=this.hasAttribute(`disabled`),n=this.tags.map((n,r)=>`<span class="k-badge${e===`neutral`?``:` k-badge--${s(e)}`}${t?``:` k-badge--removable`}">${s(n)}${t?``:`<button type="button" class="k-badge__remove" data-i="${r}" aria-label="${s(u().common.remove(n))}"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="m6 6 8 8M14 6l-8 8"/></svg></button>`}</span>`).join(``);this.input.insertAdjacentHTML(`beforebegin`,n),this.input.placeholder=this.tags.length?``:this.getAttribute(`placeholder`)??``,this.paintMessages(),g(this,this.getAttribute(`name`),this.tags)}paintMessages(){let e=this.getAttribute(`error`)||this.localError;this.querySelector(`.k-tag-input`).toggleAttribute(`data-invalid`,!!e),r(this.querySelector(`:scope > .k-field`),this.input,this.key,e,this.getAttribute(`hint`))}};_.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`disabled`,`name`,`value`,`max`,`tone`,`allow-duplicates`,`aria-label`];var v=class extends f{constructor(){super(...arguments),this.current=null,this.rendered=!1,this.valueSet=!1,this.key=m(`kashi-num`)}connectedCallback(){!this.rendered&&!this.valueSet&&(this.current=this.num(this.getAttribute(`value`))??null),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.value=n===null||n===``?null:Number(n):this.render())}get value(){return this.current}set value(e){this.valueSet=!0,this.current=e==null||Number.isNaN(Number(e))?null:Number(e),this.rendered&&this.paint()}focus(e){this.input?.focus(e)}num(e){return e===null||e===``||Number.isNaN(Number(e))?void 0:Number(e)}get min(){return this.num(this.getAttribute(`min`))}get max(){return this.num(this.getAttribute(`max`))}clamp(e){return Math.min(this.max??1/0,Math.max(this.min??-1/0,e))}show(e){if(e===null)return``;let t=this.hasAttribute(`thousands`)?o(e,{digits:`latin`}):String(e);return d(this)===`latin`?t:n(t).replace(/,/g,`٬`)}render(){let t=this.key,n=this.getAttribute(`aria-label`),r=this.hasAttribute(`label`)?this.getAttribute(`label`):n?null:u().numberInput.label,i=this.hasAttribute(`disabled`),a=this.getAttribute(`unit`),o=`<div class="k-number"><div class="k-input"${i?` data-state="disabled"`:``}><button type="button" class="k-number__step" data-step="-1" tabindex="-1" aria-label="${s(u().numberInput.decrement)}"${i?` disabled`:``}><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><path d="M5 10h10"/></svg></button><input id="${t}" class="k-input__control" type="text" inputmode="decimal" role="spinbutton" dir="ltr"${i?` disabled`:``}${!r&&n?` aria-label="${s(n)}"`:``}>${a?`<span class="k-input__addon">${s(a)}</span>`:``}<button type="button" class="k-number__step" data-step="1" tabindex="-1" aria-label="${s(u().numberInput.increment)}"${i?` disabled`:``}><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><path d="M10 5v10M5 10h10"/></svg></button></div></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,p({id:t,label:r,control:o})),this.input=this.querySelector(`input.k-input__control`),this.querySelectorAll(`.k-number__step`).forEach(e=>e.addEventListener(`click`,()=>this.bump(Number(e.dataset.step)))),this.input.addEventListener(`input`,()=>{let t=this.input.value,n=e(t);this.set(n?(/^\s*[-−]/.test(t)?-1:1)*Number(n):null,!1)}),this.input.addEventListener(`blur`,()=>{this.current!==null&&this.current!==this.clamp(this.current)?this.set(this.clamp(this.current)):this.paint()}),this.input.addEventListener(`keydown`,e=>{let t={ArrowUp:()=>this.bump(1),ArrowDown:()=>this.bump(-1),PageUp:()=>this.bump(10),PageDown:()=>this.bump(-10),Home:()=>this.min!==void 0&&this.set(this.min),End:()=>this.max!==void 0&&this.set(this.max)};t[e.key]&&(e.preventDefault(),t[e.key]())}),this.rendered=!0,this.paint()}bump(e){let t=this.num(this.getAttribute(`step`))??1;this.set(this.clamp((this.current??this.min??0)+e*t))}set(e,t=!0){let n=e!==this.current;this.current=e,t?this.paint():this.paintState(),n&&i(this,`kashi-change`,{value:e})}paint(){let e=this.show(this.current);this.input.value!==e&&(this.input.value=e),this.paintState()}paintState(){let e=this.input,t=this.current;for(let[n,r]of[[`aria-valuenow`,t],[`aria-valuemin`,this.min],[`aria-valuemax`,this.max]])r==null?e.removeAttribute(n):e.setAttribute(n,String(r));t===null?e.removeAttribute(`aria-valuetext`):e.setAttribute(`aria-valuetext`,this.show(t));let n=this.hasAttribute(`disabled`),[i,a]=this.querySelectorAll(`.k-number__step`);i.disabled=n||this.min!==void 0&&(t??0)<=this.min,a.disabled=n||this.max!==void 0&&(t??0)>=this.max,r(this.querySelector(`:scope > .k-field`),e,this.key,this.getAttribute(`error`),this.getAttribute(`hint`)),g(this,this.getAttribute(`name`),[t===null?``:String(t)])}};v.observedAttributes=[`label`,`hint`,`error`,`value`,`min`,`max`,`step`,`thousands`,`digits`,`unit`,`disabled`,`name`,`aria-label`];const y=`<svg viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="M12 2.8l2.8 5.9 6.4.8-4.7 4.4 1.2 6.3L12 17.1l-5.7 3.1 1.2-6.3L2.8 9.5l6.4-.8z"/><path class="k-rating__half" fill="none" d="M12 2.8v14.3l-5.7 3.1 1.2-6.3L2.8 9.5l6.4-.8z"/></svg>`;var b=class extends f{constructor(){super(...arguments),this.current=0,this.valueSet=!1,this.key=m(`kashi-rate`)}connectedCallback(){this.valueSet||(this.current=Number(this.getAttribute(`value`))||0),this.render()}attributeChangedCallback(e,t,n){t!==n&&this.isConnected&&(e===`value`&&(this.current=Number(n)||0),this.render())}get value(){return this.current}set value(e){this.valueSet=!0,this.current=Number(e)||0,this.isConnected&&this.render()}render(){let e=Number(this.getAttribute(`max`))||5,t=this.getAttribute(`label`)??u().rating.label,n=e=>c(this,e).replace(`.`,u().common.decimal),r=this.getAttribute(`size`),a=`k-rating${r===`sm`||r===`lg`?` k-rating--${r}`:``}`,o=this.current,l=Array.from({length:e},(e,t)=>t+1),d=this.hasAttribute(`show-value`)?`<span class="k-rating__value" aria-hidden="true">${n(o)}</span>`:``;if(this.hasAttribute(`readonly`)){this.innerHTML=`<span class="${a}" data-readonly="" role="img" aria-label="${s(`${t}: ${u().common.of(n(o),n(e))}`)}">${l.map(e=>`<span class="k-rating__star"${e<=Math.floor(o)?` data-filled=""`:``}${e===Math.ceil(o)&&o%1>=.25?` data-half=""`:``}>${y}</span>`).join(``)}${d}</span>`;return}let f=this.getAttribute(`name`)??this.key,p=this.hasAttribute(`disabled`);this.innerHTML=`<fieldset class="${a}"><legend class="k-sr-only">${s(t)}</legend>${l.map(t=>`<label class="k-rating__star"${t<=o?` data-filled=""`:``}><input type="radio" class="k-sr-only" name="${s(f)}" value="${t}"${o===t?` checked`:``}${p?` disabled`:``} aria-label="${s(u().common.of(n(t),n(e)))}">${y}</label>`).join(``)}${d}</fieldset>`;let m=this.querySelector(`fieldset`),h=e=>m.querySelectorAll(`.k-rating__star`).forEach((t,n)=>t.toggleAttribute(`data-filled`,n+1<=e));m.addEventListener(`change`,e=>{this.current=Number(e.target.value),h(this.current),i(this,`kashi-change`,{value:this.current})}),m.addEventListener(`pointerover`,e=>{let t=e.target.closest(`.k-rating__star`);t&&!p&&h([...m.querySelectorAll(`.k-rating__star`)].indexOf(t)+1)}),m.addEventListener(`pointerleave`,()=>h(this.current))}};b.observedAttributes=[`value`,`max`,`readonly`,`show-value`,`size`,`label`,`name`,`disabled`];function x(e,t,n=1){let r=[1],i=Math.max(2,e-n),a=Math.min(t-1,e+n);i>2&&r.push(i===3?2:null);for(let e=i;e<=a;e++)r.push(e);return a<t-1&&r.push(a===t-2?t-1:null),t>1&&r.push(t),r}const S=e=>`<svg data-k-mirror="" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${e}"/></svg>`;var C=class extends f{connectedCallback(){this.render()}attributeChangedCallback(e,t,n){t!==n&&this.isConnected&&this.render()}get page(){return Math.max(1,Number(this.getAttribute(`page`))||1)}set page(e){this.setAttribute(`page`,String(e))}get total(){return Math.max(1,Number(this.getAttribute(`total`))||1)}render(){let e=Math.min(this.page,this.total),t=this.total,r=e=>d(this)===`latin`?String(e):n(e),a=this.getAttribute(`href`),o=this.contains(document.activeElement)?document.activeElement.dataset.to:null,c=(e,t,n,{current:r=!1,disabled:i=!1,aria:o=``}={})=>a&&!i?`<a class="${n}" href="${s(a.replace(`{page}`,String(e)))}" data-to="${e}"${r?` aria-current="page"`:``}${o?` aria-label="${s(o)}"`:``}>${t}</a>`:`<button type="button" class="${n}" data-to="${e}"${i?` disabled`:``}${r?` aria-current="page"`:``}${o?` aria-label="${s(o)}"`:``}>${t}</button>`,l=this.getAttribute(`summary`);this.innerHTML=`<nav class="k-pagination" aria-label="${s(this.getAttribute(`label`)??u().pagination.nav)}">${c(e-1,`${S(`m12 5-5 5 5 5`)}${s(u().common.prev)}`,`k-btn k-btn--secondary k-btn--sm`,{disabled:e<=1})}${l?`<span class="k-pagination__summary">${s(l)}</span>`:``}<ul class="k-pagination__pages" role="list">${x(e,t,Number(this.getAttribute(`siblings`)??1)).map(t=>`<li>${t===null?`<span class="k-pagination__ellipsis" aria-hidden="true">…</span>`:c(t,r(t),`k-pagination__page`,{current:t===e,aria:u().pagination.page(r(t))})}</li>`).join(``)}</ul>${c(e+1,`${s(u().common.next)}${S(`m8 5 5 5-5 5`)}`,`k-btn k-btn--secondary k-btn--sm`,{disabled:e>=t})}</nav>`,this.querySelector(`nav`).addEventListener(`click`,e=>{let t=e.target.closest(`button[data-to]`);if(!t||t.disabled)return;let n=Number(t.dataset.to);this.setAttribute(`page`,String(n)),i(this,`kashi-change`,{page:n}),this.querySelector(`.k-pagination__page[data-to="${n}"]`)?.focus()}),o&&this.querySelector(`[data-to="${o}"]`)?.focus()}};C.observedAttributes=[`page`,`total`,`siblings`,`href`,`digits`,`label`,`summary`];const w=e=>{let n=t(e).replace(/[٬,\s]/g,``).replace(`٫`,`.`).replace(`−`,`-`).match(/-?\d+(\.\d+)?/);return n?Number(n[0]):NaN};l(`kashi-tag-input`,_,`block`),l(`kashi-number-input`,v,`block`),l(`kashi-rating`,b),l(`kashi-pagination`,C,`block`);export{v as KashiNumberInput,C as KashiPagination,b as KashiRating,_ as KashiTagInput,w as cellNumber,x as pageRange};
@@ -1 +1 @@
1
- import{C as e,P as t,c as n,d as r,l as i,o as a,p as o,s,t as c,w as l}from"./base-D4tCOysh.js";import{n as u,r as d,t as f}from"./money-CjGI2VIQ.js";import{t as p}from"./relative-OC1fV3Xh.js";import{t as m}from"./words-BdADG_9U.js";const h=e=>{if(!e)return null;let t=l(e.trim())??new Date(e);return Number.isNaN(t.getTime())?null:t};var g=class extends c{connectedCallback(){this.render()}attributeChangedCallback(){this.isConnected&&this.render()}},_=class extends g{render(){let e=Number(this.getAttribute(`value`)??0),t=this.getAttribute(`unit`)===`rial`?`rial`:`toman`,n=this.getAttribute(`from`)===`rial`?`rial`:this.getAttribute(`from`)===`toman`?`toman`:t,a=this.hasAttribute(`compact`),c=s(this),l=this.hasAttribute(`signed`),p=this.getAttribute(`size`)??`md`,h=n===t?e:n===`rial`?u(e):d(e),g=r(),_=o(),v=f(h,{unit:t,compact:a,digits:c,locale:g,showUnit:!1}),y=f(h,{unit:t,compact:a,locale:g}),b=t===`toman`?_.money.toman:_.money.rial,x=y.endsWith(`همت`)?null:b,S=this.getAttribute(`words`)!==`false`&&Number.isSafeInteger(Math.round(h))?`${m(Math.round(h),{locale:g})} ${b}`:null,C=l?h>0?`positive`:h<0?`negative`:null:null,w=S?` aria-hidden="true"`:``;this.innerHTML=`<data value="${h}" class="k-money k-money--${i(p)}"${C?` data-tone="${C}"`:``}${S?` title="${i(S)}"`:``}><span class="k-money__amount"${w}>${l&&h>0?`+`:``}${i(v)}</span>${x?`<span class="k-money__unit"${w}>${x}</span>`:``}${S?`<span class="k-sr-only">${h<0?``:l&&h>0?_.money.positive:``}${i(S)}</span>`:``}</data>`}};_.observedAttributes=[`value`,`unit`,`from`,`compact`,`digits`,`signed`,`words`,`size`];var v=class extends g{render(){let t=h(this.getAttribute(`datetime`));if(!t){this.textContent=``;return}let n=this.getAttribute(`format`),a=n===`numeric`||n===`full`?n:`long`,o=s(this);this.innerHTML=`<time datetime="${i(this.getAttribute(`datetime`))}">${i(e(t,{style:a,digits:o,locale:r()}))}</time>`}};v.observedAttributes=[`datetime`,`format`,`digits`];var y=class extends g{connectedCallback(){super.connectedCallback(),clearInterval(this.timer),this.timer=setInterval(()=>this.render(),Number(this.getAttribute(`refresh`))||6e4)}disconnectedCallback(){clearInterval(this.timer)}render(){let t=h(this.getAttribute(`datetime`));if(!t){this.textContent=``;return}let n=s(this);this.innerHTML=`<time datetime="${t.toISOString()}" title="${i(e(t,{style:`full`,digits:n,locale:r()}))}">${i(p(t,{digits:n,locale:r()}))}</time>`}};y.observedAttributes=[`datetime`,`digits`,`refresh`];const b=e=>String(e).padStart(2,`0`);var x=class extends c{constructor(){super(...arguments),this.end=0,this.done=!1}connectedCallback(){this.restart()}disconnectedCallback(){clearInterval(this.timer)}attributeChangedCallback(e,t,n){this.isConnected&&t!==n&&(e===`to`||e===`seconds`?this.restart():this.render())}restart(){let e=h(this.getAttribute(`to`));this.end=e?e.getTime():Date.now()+(Number(this.getAttribute(`seconds`))||0)*1e3,this.done=!1,clearInterval(this.timer),this.render(),this.timer=setInterval(()=>this.render(),1e3)}get remaining(){return Math.max(0,Math.ceil((this.end-Date.now())/1e3))}render(){let e=this.remaining,r=Math.floor(e/86400),a=Math.floor(e%86400/3600),c=Math.floor(e%3600/60),l=e%60,u=s(this)===`fa`,d=e=>u?t(String(e)):String(e),f=o().countdown,p=[r&&`${d(r)} ${f.days}`,a&&`${d(a)} ${f.hours}`,c&&`${d(c)} ${f.minutes}`,`${d(l)} ${f.seconds}`].filter(Boolean).join(o().common.and),m=this.getAttribute(`label`),h=i(m?`${m}: ${p}`:p),g=e===0?` data-done=""`:``;if(this.getAttribute(`variant`)===`blocks`){let e=[...r?[[r,f.days]]:[],[a,f.hours],[c,f.minutes],[l,f.seconds]];this.innerHTML=`<div role="timer" aria-label="${h}" class="k-countdown k-countdown--blocks"${g}>${e.map(([e,t])=>`<span class="k-countdown__unit" aria-hidden="true"><span class="k-countdown__num">${d(b(e))}</span><span class="k-countdown__name">${t}</span></span>`).join(``)}</div>`}else{let e=(r?`${r}:`:``)+(a||r?`${b(a)}:`:``)+`${b(c)}:${b(l)}`;this.innerHTML=`<span role="timer" aria-label="${h}" class="k-countdown"${g} dir="ltr"><span aria-hidden="true">${d(e)}</span></span>`}e===0&&(clearInterval(this.timer),this.done||(this.done=!0,n(this,`kashi-complete`,{})))}};x.observedAttributes=[`to`,`seconds`,`variant`,`digits`,`label`],a(`kashi-money`,_),a(`kashi-date`,v),a(`kashi-relative-time`,y),a(`kashi-countdown`,x);export{x as KashiCountdown,v as KashiDate,_ as KashiMoney,y as KashiRelativeTime};
1
+ import{C as e,P as t,c as n,d as r,l as i,o as a,p as o,s,t as c,w as l}from"./base-BqFAMlwG.js";import{n as u,r as d,t as f}from"./money-BFEbgLJn.js";import{t as p}from"./relative-BoBZPiB7.js";import{t as m}from"./words-BdADG_9U.js";const h=e=>{if(!e)return null;let t=l(e.trim())??new Date(e);return Number.isNaN(t.getTime())?null:t};var g=class extends c{connectedCallback(){this.render()}attributeChangedCallback(){this.isConnected&&this.render()}},_=class extends g{render(){let e=Number(this.getAttribute(`value`)??0),t=this.getAttribute(`unit`)===`rial`?`rial`:`toman`,n=this.getAttribute(`from`)===`rial`?`rial`:this.getAttribute(`from`)===`toman`?`toman`:t,a=this.hasAttribute(`compact`),c=s(this),l=this.hasAttribute(`signed`),p=this.getAttribute(`size`)??`md`,h=n===t?e:n===`rial`?u(e):d(e),g=r(),_=o(),v=f(h,{unit:t,compact:a,digits:c,locale:g,showUnit:!1}),y=f(h,{unit:t,compact:a,locale:g}),b=t===`toman`?_.money.toman:_.money.rial,x=y.endsWith(`همت`)?null:b,S=this.getAttribute(`words`)!==`false`&&Number.isSafeInteger(Math.round(h))?`${m(Math.round(h),{locale:g})} ${b}`:null,C=l?h>0?`positive`:h<0?`negative`:null:null,w=S?` aria-hidden="true"`:``;this.innerHTML=`<data value="${h}" class="k-money k-money--${i(p)}"${C?` data-tone="${C}"`:``}${S?` title="${i(S)}"`:``}><span class="k-money__amount"${w}>${l&&h>0?`+`:``}${i(v)}</span>${x?`<span class="k-money__unit"${w}>${x}</span>`:``}${S?`<span class="k-sr-only">${h<0?``:l&&h>0?_.money.positive:``}${i(S)}</span>`:``}</data>`}};_.observedAttributes=[`value`,`unit`,`from`,`compact`,`digits`,`signed`,`words`,`size`];var v=class extends g{render(){let t=h(this.getAttribute(`datetime`));if(!t){this.textContent=``;return}let n=this.getAttribute(`format`),a=n===`numeric`||n===`full`?n:`long`,o=s(this);this.innerHTML=`<time datetime="${i(this.getAttribute(`datetime`))}">${i(e(t,{style:a,digits:o,locale:r()}))}</time>`}};v.observedAttributes=[`datetime`,`format`,`digits`];var y=class extends g{connectedCallback(){super.connectedCallback(),clearInterval(this.timer),this.timer=setInterval(()=>this.render(),Number(this.getAttribute(`refresh`))||6e4)}disconnectedCallback(){clearInterval(this.timer)}render(){let t=h(this.getAttribute(`datetime`));if(!t){this.textContent=``;return}let n=s(this);this.innerHTML=`<time datetime="${t.toISOString()}" title="${i(e(t,{style:`full`,digits:n,locale:r()}))}">${i(p(t,{digits:n,locale:r()}))}</time>`}};y.observedAttributes=[`datetime`,`digits`,`refresh`];const b=e=>String(e).padStart(2,`0`);var x=class extends c{constructor(){super(...arguments),this.end=0,this.done=!1}connectedCallback(){this.restart()}disconnectedCallback(){clearInterval(this.timer)}attributeChangedCallback(e,t,n){this.isConnected&&t!==n&&(e===`to`||e===`seconds`?this.restart():this.render())}restart(){let e=h(this.getAttribute(`to`));this.end=e?e.getTime():Date.now()+(Number(this.getAttribute(`seconds`))||0)*1e3,this.done=!1,clearInterval(this.timer),this.render(),this.timer=setInterval(()=>this.render(),1e3)}get remaining(){return Math.max(0,Math.ceil((this.end-Date.now())/1e3))}render(){let e=this.remaining,r=Math.floor(e/86400),a=Math.floor(e%86400/3600),c=Math.floor(e%3600/60),l=e%60,u=s(this)===`fa`,d=e=>u?t(String(e)):String(e),f=o().countdown,p=[r&&`${d(r)} ${f.days}`,a&&`${d(a)} ${f.hours}`,c&&`${d(c)} ${f.minutes}`,`${d(l)} ${f.seconds}`].filter(Boolean).join(o().common.and),m=this.getAttribute(`label`),h=i(m?`${m}: ${p}`:p),g=e===0?` data-done=""`:``;if(this.getAttribute(`variant`)===`blocks`){let e=[...r?[[r,f.days]]:[],[a,f.hours],[c,f.minutes],[l,f.seconds]];this.innerHTML=`<div role="timer" aria-label="${h}" class="k-countdown k-countdown--blocks"${g}>${e.map(([e,t])=>`<span class="k-countdown__unit" aria-hidden="true"><span class="k-countdown__num">${d(b(e))}</span><span class="k-countdown__name">${t}</span></span>`).join(``)}</div>`}else{let e=(r?`${r}:`:``)+(a||r?`${b(a)}:`:``)+`${b(c)}:${b(l)}`;this.innerHTML=`<span role="timer" aria-label="${h}" class="k-countdown"${g} dir="ltr"><span aria-hidden="true">${d(e)}</span></span>`}e===0&&(clearInterval(this.timer),this.done||(this.done=!0,n(this,`kashi-complete`,{})))}};x.observedAttributes=[`to`,`seconds`,`variant`,`digits`,`label`],a(`kashi-money`,_),a(`kashi-date`,v),a(`kashi-relative-time`,y),a(`kashi-countdown`,x);export{x as KashiCountdown,v as KashiDate,_ as KashiMoney,y as KashiRelativeTime};
@@ -1 +1 @@
1
- import{M as e,P as t,_ as n,c as r,l as i,o as a,p as o,s,t as c,u as l,v as u,y as d}from"./base-D4tCOysh.js";var f=class extends c{constructor(){super(...arguments),this.code=``,this.caret=0,this.valueSet=!1,this.rendered=!1,this.key=d(`kashi-otp`)}connectedCallback(){!this.rendered&&!this.valueSet&&(this.code=e(this.getAttribute(`value`)??``).slice(0,this.length)),this.render()}attributeChangedCallback(t,n,r){this.rendered&&n!==r&&(t===`value`?(this.code=e(r??``).slice(0,this.length),this.paint()):this.render())}get value(){return this.code}set value(t){this.valueSet=!0,this.code=e(String(t??``)).slice(0,this.length),this.rendered&&this.paint()}focus(e){this.input?.focus(e)}get length(){let e=Number(this.getAttribute(`length`));return Number.isInteger(e)&&e>0?e:6}render(){let t=this.key,n=this.length,a=Number(this.getAttribute(`group-after`))||0,s=this.getAttribute(`aria-label`),c=this.hasAttribute(`label`)?this.getAttribute(`label`):s?null:o().otp.label,u=Array.from({length:n},(e,t)=>`${a&&t===a?`<span class="k-otp__sep" aria-hidden="true"></span>`:``}<span class="k-otp__slot" aria-hidden="true"></span>`).join(``),d=`<div class="k-otp${this.getAttribute(`size`)===`sm`?` k-otp--sm`:``}"><input id="${t}" class="k-otp__input" type="text" inputmode="numeric" autocomplete="one-time-code" pattern="\\d*" maxlength="${n*2}"${this.hasAttribute(`disabled`)?` disabled`:``}${!c&&s?` aria-label="${i(s)}"`:``}>${u}</div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,l({id:t,label:c,control:d})),this.input=this.querySelector(`.k-otp__input`),this.querySelector(`.k-otp`).addEventListener(`click`,()=>this.input.focus()),this.input.addEventListener(`input`,()=>{let t=e(this.input.value).slice(0,this.length),n=this.code;this.code=t,this.caret=t.length,this.paint(),t!==n&&r(this,`kashi-change`,{value:t}),t.length===this.length&&t!==n&&r(this,`kashi-complete`,{value:t})});let f=()=>{this.caret=Math.min(this.input.selectionStart??this.code.length,this.length),this.paintSlots()};for(let e of[`select`,`keyup`,`focus`])this.input.addEventListener(e,f);this.input.addEventListener(`blur`,()=>this.paintSlots()),this.rendered=!0,this.paint()}paint(){this.input.value!==this.code&&(this.input.value=this.code),this.paintSlots();let e=this.getAttribute(`error`);this.querySelector(`.k-otp`).classList.toggle(`k-otp--invalid`,!!e),n(this.querySelector(`:scope > .k-field`),this.input,this.key,e,this.getAttribute(`hint`)),u(this,this.getAttribute(`name`),this.code)}paintSlots(){let e=s(this)===`fa`,n=this.ownerDocument.activeElement===this.input,r=Math.min(this.caret,this.length-1);this.querySelectorAll(`.k-otp__slot`).forEach((i,a)=>{let o=this.code[a]??``;i.textContent=e?t(o):o,i.toggleAttribute(`data-filled`,!!o),i.toggleAttribute(`data-active`,n&&a===r)})}};f.observedAttributes=[`label`,`hint`,`error`,`length`,`digits`,`group-after`,`size`,`disabled`,`name`,`value`,`aria-label`],a(`kashi-otp`,f,`block`);export{f as KashiOtp};
1
+ import{M as e,P as t,_ as n,c as r,l as i,o as a,p as o,s,t as c,u as l,v as u,y as d}from"./base-BqFAMlwG.js";var f=class extends c{constructor(){super(...arguments),this.code=``,this.caret=0,this.valueSet=!1,this.rendered=!1,this.key=d(`kashi-otp`)}connectedCallback(){!this.rendered&&!this.valueSet&&(this.code=e(this.getAttribute(`value`)??``).slice(0,this.length)),this.render()}attributeChangedCallback(t,n,r){this.rendered&&n!==r&&(t===`value`?(this.code=e(r??``).slice(0,this.length),this.paint()):this.render())}get value(){return this.code}set value(t){this.valueSet=!0,this.code=e(String(t??``)).slice(0,this.length),this.rendered&&this.paint()}focus(e){this.input?.focus(e)}get length(){let e=Number(this.getAttribute(`length`));return Number.isInteger(e)&&e>0?e:6}render(){let t=this.key,n=this.length,a=Number(this.getAttribute(`group-after`))||0,s=this.getAttribute(`aria-label`),c=this.hasAttribute(`label`)?this.getAttribute(`label`):s?null:o().otp.label,u=Array.from({length:n},(e,t)=>`${a&&t===a?`<span class="k-otp__sep" aria-hidden="true"></span>`:``}<span class="k-otp__slot" aria-hidden="true"></span>`).join(``),d=`<div class="k-otp${this.getAttribute(`size`)===`sm`?` k-otp--sm`:``}"><input id="${t}" class="k-otp__input" type="text" inputmode="numeric" autocomplete="one-time-code" pattern="\\d*" maxlength="${n*2}"${this.hasAttribute(`disabled`)?` disabled`:``}${!c&&s?` aria-label="${i(s)}"`:``}>${u}</div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,l({id:t,label:c,control:d})),this.input=this.querySelector(`.k-otp__input`),this.querySelector(`.k-otp`).addEventListener(`click`,()=>this.input.focus()),this.input.addEventListener(`input`,()=>{let t=e(this.input.value).slice(0,this.length),n=this.code;this.code=t,this.caret=t.length,this.paint(),t!==n&&r(this,`kashi-change`,{value:t}),t.length===this.length&&t!==n&&r(this,`kashi-complete`,{value:t})});let f=()=>{this.caret=Math.min(this.input.selectionStart??this.code.length,this.length),this.paintSlots()};for(let e of[`select`,`keyup`,`focus`])this.input.addEventListener(e,f);this.input.addEventListener(`blur`,()=>this.paintSlots()),this.rendered=!0,this.paint()}paint(){this.input.value!==this.code&&(this.input.value=this.code),this.paintSlots();let e=this.getAttribute(`error`);this.querySelector(`.k-otp`).classList.toggle(`k-otp--invalid`,!!e),n(this.querySelector(`:scope > .k-field`),this.input,this.key,e,this.getAttribute(`hint`)),u(this,this.getAttribute(`name`),this.code)}paintSlots(){let e=s(this)===`fa`,n=this.ownerDocument.activeElement===this.input,r=Math.min(this.caret,this.length-1);this.querySelectorAll(`.k-otp__slot`).forEach((i,a)=>{let o=this.code[a]??``;i.textContent=e?t(o):o,i.toggleAttribute(`data-filled`,!!o),i.toggleAttribute(`data-active`,n&&a===r)})}};f.observedAttributes=[`label`,`hint`,`error`,`length`,`digits`,`group-after`,`size`,`disabled`,`name`,`value`,`aria-label`],a(`kashi-otp`,f,`block`);export{f as KashiOtp};
@@ -0,0 +1 @@
1
+ import{M as e,P as t,_ as n,c as r,d as i,f as a,i as o,j as s,l as c,m as l,o as u,p as d,r as f,s as p,t as m,u as h,v as g,y as _}from"./base-BqFAMlwG.js";import{i as v,r as y}from"./search-BvShDz2X.js";import{t as b}from"./text-DFyW6cuq.js";import{n as x,t as S}from"./time-oyKIQ2bk.js";import{n as C}from"./combobox-Drm8K9Zk.js";const w=[`الف`,`ب`,`پ`,`ت`,`ث`,`ج`,`د`,`ز`,`س`,`ش`,`ص`,`ط`,`ع`,`ف`,`ق`,`ک`,`گ`,`ل`,`م`,`ن`,`و`,`ه`,`ی`,`ژ`],T={الف:`government`,پ:`police`,ث:`police`,ت:`taxi`,ع:`public`,ک:`agricultural`,ش:`army`,ز:`defense`,ف:`defense`,ژ:`disabled`};function E(e){return T[e]??`private`}function D(t){let n=e(t.first??``),r=e(t.middle??``),i=e(t.region??``);return/^[1-9]\d$/.test(n)&&/^[1-9]\d{2}$/.test(r)&&/^[1-9]\d$/.test(i)&&w.includes(t.letter??``)}function O(n,{digits:r=`fa`}={}){let i=n=>r===`fa`?t(e(n)):e(n);return`${i(n.first)} ${n.letter} ${i(n.middle)} ایران ${i(n.region)}`}const k=`<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m5 10.5 3.2 3L15 7"/></svg>`,A=`<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="m6 6 8 8M14 6l-8 8"/></svg>`;function j(e,t,n){if(e.querySelectorAll(`:scope > input[type=hidden][data-kashi-value]`).forEach(e=>e.remove()),t)for(let r of n)e.insertAdjacentHTML(`beforeend`,`<input type="hidden" data-kashi-value name="${c(t)}" value="${c(r)}">`)}function M(e){let t=[...e.querySelectorAll(`:scope > option`)].map(e=>({value:e.value,label:e.textContent?.trim()??e.value,description:e.dataset.description,disabled:e.disabled,selected:e.hasAttribute(`selected`)}));return e.querySelectorAll(`:scope > option`).forEach(e=>e.remove()),t}var N=class extends m{constructor(){super(...arguments),this.list=null,this.chosen=[],this.query=``,this.active=-1,this.isOpen=!1,this.valueSet=!1,this.key=_(`kashi-multi`),this.onOutside=e=>{this.contains(e.target)||this.close()}}connectedCallback(){f(()=>{if(this.isConnected){if(this.list===null){let e=M(this);this.list=e,this.valueSet||(this.chosen=e.filter(e=>e.selected).map(e=>e.value))}this.render()}})}disconnectedCallback(){document.removeEventListener(`pointerdown`,this.onOutside)}attributeChangedCallback(e,t,n){this.box&&t!==n&&this.render()}get options(){return this.list??[]}set options(e){this.list=[...e],this.box&&this.paint()}get value(){return[...this.chosen]}set value(e){this.valueSet=!0,this.chosen=[...e],this.box&&this.paint()}render(){let e=this.key,t=this.getAttribute(`aria-label`),n=this.hasAttribute(`label`)?this.getAttribute(`label`):t?null:d().multiSelect.label,r=`<div class="k-combobox k-multiselect"><div class="k-tag-input"><input id="${e}" class="k-tag-input__control" role="combobox" aria-autocomplete="list" aria-expanded="false" aria-controls="${e}-list" autocomplete="off"${this.hasAttribute(`disabled`)?` disabled`:``}${!n&&t?` aria-label="${c(t)}"`:``}></div><ul id="${e}-list" role="listbox" aria-multiselectable="true" class="k-listbox" hidden style="inset-block-start: calc(100% + 6px)"${n?` aria-label="${c(n)}"`:``}></ul><span id="${e}-count" class="k-sr-only"></span><span class="k-sr-only" aria-live="polite"></span></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,h({id:e,label:n,control:r})),this.input=this.querySelector(`.k-tag-input__control`),this.box=this.querySelector(`.k-tag-input`),this.listbox=this.querySelector(`.k-listbox`),this.box.addEventListener(`click`,e=>{let t=e.target.closest(`[data-remove]`);t?this.set(this.chosen.filter(e=>e!==t.dataset.remove),d().common.removed(this.labelOf(t.dataset.remove))):e.target.closest(`[data-clear]`)&&this.set([],d().multiSelect.clearedAll),this.input.focus()}),this.input.addEventListener(`input`,()=>{this.query=this.input.value,this.active=0,this.open()}),this.input.addEventListener(`focus`,()=>this.open()),this.input.addEventListener(`keydown`,e=>this.onKey(e)),this.listbox.addEventListener(`pointerdown`,e=>e.preventDefault()),this.listbox.addEventListener(`click`,e=>{let t=e.target.closest(`[role="option"]`);t&&this.toggle(this.filtered()[Number(t.dataset.i)])}),this.paint()}labelOf(e){return this.options.find(t=>t.value===e)?.label??e}filtered(){let e=C(this.query.trim());return this.options.filter(t=>!e||[t.label,t.description??``].some(t=>C(t).includes(e)))}get full(){let e=Number(this.getAttribute(`max`));return!!e&&this.chosen.length>=e}toggle(e){if(!e||e.disabled)return;let t=this.chosen.includes(e.value);if(!t&&this.full)return this.announce(d().common.max(l(this,Number(this.getAttribute(`max`)))));this.query=``,this.input.value=``,this.set(t?this.chosen.filter(t=>t!==e.value):[...this.chosen,e.value],t?d().common.removed(e.label):d().common.selected(e.label))}set(e,t){this.chosen=e,this.paint(),this.announce(t),r(this,`kashi-change`,{value:[...e]})}announce(e){this.querySelector(`.k-multiselect > .k-sr-only[aria-live]`).textContent=e}open(){this.hasAttribute(`disabled`)||(this.isOpen=!0,this.listbox.hidden=!1,this.input.setAttribute(`aria-expanded`,`true`),this.querySelector(`.k-combobox`).setAttribute(`data-open`,``),document.addEventListener(`pointerdown`,this.onOutside),this.paintList())}close(){this.isOpen=!1,this.listbox.hidden=!0,this.input.setAttribute(`aria-expanded`,`false`),this.input.removeAttribute(`aria-activedescendant`),this.querySelector(`.k-combobox`).removeAttribute(`data-open`),document.removeEventListener(`pointerdown`,this.onOutside)}onKey(e){let t=this.filtered(),n=t.map((e,t)=>e.disabled?-1:t).filter(e=>e>=0),r=e=>{n.length&&(this.active=n[(n.indexOf(this.active)+e+n.length)%n.length],this.paintList())};if(e.key===`ArrowDown`)e.preventDefault(),this.isOpen?r(1):this.open();else if(e.key===`ArrowUp`)e.preventDefault(),this.isOpen?r(-1):this.open();else if(e.key===`Enter`&&this.isOpen&&t[this.active])e.preventDefault(),this.toggle(t[this.active]);else if(e.key===`Escape`&&this.isOpen)e.preventDefault(),this.close();else if(e.key===`Backspace`&&!this.input.value&&this.chosen.length){let e=this.chosen.at(-1);this.set(this.chosen.slice(0,-1),d().common.removed(this.labelOf(e)))}}paint(){let e=this.hasAttribute(`disabled`);this.box.querySelectorAll(`.k-badge, [data-clear]`).forEach(e=>e.remove());let t=this.chosen.map(t=>`<span class="k-badge k-badge--brand${e?``:` k-badge--removable`}">${c(this.labelOf(t))}${e?``:`<button type="button" class="k-badge__remove" data-remove="${c(t)}" aria-label="${c(d().common.remove(this.labelOf(t)))}">${A}</button>`}</span>`).join(``);this.input.insertAdjacentHTML(`beforebegin`,t),this.chosen.length>1&&!e&&this.box.insertAdjacentHTML(`beforeend`,`<button type="button" class="k-input__action" data-clear aria-label="${c(d().common.clearAll)}">${A}</button>`),this.input.placeholder=this.chosen.length?``:this.getAttribute(`placeholder`)??``,this.querySelector(`#${this.key}-count`).textContent=d().multiSelect.selected(l(this,this.chosen.length));let r=this.getAttribute(`error`);this.box.toggleAttribute(`data-invalid`,!!r),n(this.querySelector(`:scope > .k-field`),this.input,this.key,r,this.getAttribute(`hint`),`${this.key}-count`),j(this,this.getAttribute(`name`),this.chosen),this.isOpen&&this.paintList()}paintList(){let e=this.filtered(),t=C(this.query.trim()),n=this.full,r=e=>{let n=t?C(e).indexOf(t):-1;return n<0?c(e):`${c(e.slice(0,n))}<mark>${c(e.slice(n,n+t.length))}</mark>${c(e.slice(n+t.length))}`};this.listbox.innerHTML=e.length?e.map((e,t)=>{let i=this.chosen.includes(e.value);return`<li id="${this.key}-list-${t}" data-i="${t}" role="option" aria-selected="${i}"${e.disabled||!i&&n?` aria-disabled="true"`:``}${t===this.active?` data-active`:``} class="k-option k-option--check"><span class="k-multiselect__box" aria-hidden="true">${i?k:``}</span><span class="k-option__body"><span>${r(e.label)}</span>${e.description?`<span class="k-option__desc">${c(e.description)}</span>`:``}</span></li>`}).join(``):`<li class="k-listbox__empty" role="presentation">${c(d().common.noResults)}</li>`;let i=this.active>=0?this.listbox.querySelector(`[data-i="${this.active}"]`):null;i?(this.input.setAttribute(`aria-activedescendant`,i.id),i.scrollIntoView?.({block:`nearest`})):this.input.removeAttribute(`aria-activedescendant`)}};N.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`max`,`disabled`,`name`,`aria-label`];var P=class extends m{constructor(){super(...arguments),this.lo=0,this.hi=0,this.valueSet=!1,this.rendered=!1,this.key=_(`kashi-slider`)}connectedCallback(){!this.rendered&&!this.valueSet&&this.readValue(this.getAttribute(`value`)),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`&&this.readValue(n),this.render())}num(e,t){let n=this.getAttribute(e);return n===null||n===``||Number.isNaN(Number(n))?t:Number(n)}get min(){return this.num(`min`,0)}get max(){return this.num(`max`,100)}get isRange(){return this.hasAttribute(`range`)}readValue(e){let t=(e??``).split(/[,،]/).map(e=>Number(e.trim())).filter(e=>!Number.isNaN(e)&&String(e)!==``);this.isRange?[this.lo,this.hi]=[t[0]??this.min,t[1]??this.max]:[this.lo,this.hi]=[this.min,t[0]??this.min]}get value(){return this.isRange?[this.lo,this.hi]:this.hi}set value(e){this.valueSet=!0,this.readValue(Array.isArray(e)?e.join(`,`):String(e)),this.rendered&&this.render()}fmt(e){let t=this.getAttribute(`unit`);return`${s(e,{digits:p(this)})}${t?` ${t}`:``}`}render(){let e=this.getAttribute(`label`),t=this.isRange,n=this.getAttribute(`name`),i=this.hasAttribute(`disabled`),a=e=>`${(e-this.min)/(this.max-this.min)*100}%`,o=r=>{let a=r===`lo`?this.lo:this.hi,o=n?t?`${n}_${r===`lo`?`min`:`max`}`:n:``;return`<input type="range" class="k-slider__input" data-which="${r}" min="${this.min}" max="${this.max}" step="${this.num(`step`,1)}" value="${a}"${i?` disabled`:``}${o?` name="${c(o)}"`:``}${t?` aria-label="${c(r===`lo`?d().slider.from:d().slider.to)}${e?` ${c(e)}`:``}"`:e?` aria-labelledby="${this.key}-label"`:``} aria-valuetext="${c(this.fmt(a))}">`},s=(this.getAttribute(`marks`)??``).split(/[,،]/).map(e=>e.trim()).filter(Boolean).map(Number),l=this.getAttribute(`show-value`)!==`false`;this.innerHTML=`<div class="k-slider"${t?` data-range=""`:``}>${e||l?`<div class="k-slider__head">${e?`<span class="k-label" id="${this.key}-label">${c(e)}</span>`:``}${l?`<span class="k-slider__value" aria-hidden="true">${c(t?`${this.fmt(this.lo)}${d().common.range}${this.fmt(this.hi)}`:this.fmt(this.hi))}</span>`:``}</div>`:``}<div class="k-slider__track" style="--_from: ${t?a(this.lo):`0%`}; --_to: ${a(this.hi)}"><span class="k-slider__fill" aria-hidden="true"></span>${t?o(`lo`):``}${o(`hi`)}</div>${s.length?`<div class="k-slider__marks" aria-hidden="true">${s.map(e=>`<span>${c(this.fmt(e))}</span>`).join(``)}</div>`:``}</div>`,this.rendered=!0,this.querySelectorAll(`.k-slider__input`).forEach(e=>e.addEventListener(`input`,()=>{let n=Number(e.value);t?e.dataset.which===`lo`?this.lo=Math.min(n,this.hi):this.hi=Math.max(n,this.lo):this.hi=n,e.value=String(e.dataset.which===`lo`?this.lo:this.hi),e.setAttribute(`aria-valuetext`,this.fmt(Number(e.value)));let i=this.querySelector(`.k-slider__track`);i.style.setProperty(`--_from`,t?a(this.lo):`0%`),i.style.setProperty(`--_to`,a(this.hi));let o=this.querySelector(`.k-slider__value`);o&&(o.textContent=t?`${this.fmt(this.lo)}${d().common.range}${this.fmt(this.hi)}`:this.fmt(this.hi)),r(this,`kashi-change`,{value:this.value})}))}};P.observedAttributes=[`label`,`min`,`max`,`step`,`value`,`range`,`show-value`,`marks`,`unit`,`disabled`,`name`];var F=class extends m{constructor(){super(...arguments),this.built=!1}connectedCallback(){f(()=>this.isConnected&&!this.built&&this.build())}attributeChangedCallback(){if(!this.built)return;let e=this.getAttribute(`label`);e&&this.setAttribute(`aria-label`,e),this.sync(!1)}get value(){return[...this.querySelectorAll(`.k-chip[aria-pressed="true"]`)].map(e=>e.dataset.value??``)}set value(e){this.querySelectorAll(`.k-chip`).forEach(t=>t.setAttribute(`aria-pressed`,String(e.includes(t.dataset.value??``)))),this.sync(!1)}build(){this.built=!0,this.classList.add(`k-chips`),this.setAttribute(`role`,`group`);let e=this.getAttribute(`label`);e&&this.setAttribute(`aria-label`,e),this.querySelectorAll(`:scope > button`).forEach(e=>{var t;e.type=`button`,e.classList.add(`k-chip`),(t=e.dataset).value||(t.value=e.textContent?.trim()??``),e.setAttribute(`aria-pressed`,String(e.hasAttribute(`data-pressed`)||e.getAttribute(`aria-pressed`)===`true`)),e.insertAdjacentHTML(`afterbegin`,`<svg class="k-chip__check" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m5 10.5 3.2 3L15 7"/></svg>`),e.dataset.count&&e.insertAdjacentHTML(`beforeend`,`<span class="k-chip__count">${l(this,e.dataset.count??``)}</span>`)}),this.addEventListener(`click`,e=>{let t=e.target.closest(`.k-chip`);if(!t||t.disabled)return;let n=t.getAttribute(`aria-pressed`)!==`true`;o(this,`single`)&&this.querySelectorAll(`.k-chip`).forEach(e=>e.setAttribute(`aria-pressed`,`false`)),t.setAttribute(`aria-pressed`,String(n)),this.sync(!0)}),this.sync(!1)}sync(e){j(this,this.getAttribute(`name`),this.value),e&&r(this,`kashi-change`,{value:this.value})}};F.observedAttributes=[`label`,`single`,`name`];const I=[[e=>e.length(a()===`fa`?t(8):`8`),e=>e.length>=8],[e=>e.cases,e=>/[a-z]/.test(e)&&/[A-Z]/.test(e)],[e=>e.digit,e=>/\d/.test(e)],[e=>e.symbol,e=>/[^A-Za-z0-9\s؀-ۿ]/.test(e)]];var L=class extends m{constructor(){super(...arguments),this.target=null,this.onInput=()=>this.render(this.target?.value??``)}connectedCallback(){f(()=>{this.isConnected&&(this.attach(),this.render(``))})}disconnectedCallback(){this.target?.removeEventListener(`input`,this.onInput)}attributeChangedCallback(){this.isConnected&&(this.attach(),this.render(this.target?.value??``))}attach(){this.target?.removeEventListener(`input`,this.onInput);let e=this.getAttribute(`for`),t=e?document.getElementById(e):null;if(this.target=t instanceof HTMLInputElement?t:t?.querySelector(`input`)??null,this.target?.addEventListener(`input`,this.onInput),this.target){this.id||=_(`kashi-strength`);let e=(this.target.getAttribute(`aria-describedby`)??``).split(` `).filter(Boolean);e.includes(this.id)||this.target.setAttribute(`aria-describedby`,[...e,this.id].join(` `))}}score(e){let t=I.filter(([,t])=>t(e)).length;return e?Math.max(1,Math.round(t/I.length*4)):0}render(e){let t=this.score(e),n=d().password,r=n.levels,i=/[؀-ۿ]/.test(e);this.innerHTML=`<div class="k-strength" data-score="${t}"><div class="k-strength__bars" aria-hidden="true">${`<span class="k-strength__bar"></span>`.repeat(4)}</div><p class="k-strength__label" aria-live="polite" style="margin: 0">${t?c(n.strength(`\0`)).replace(`\0`,`<strong>${c(r[t-1])}</strong>`):``}</p>${i?`<p class="k-hint k-hint--error" role="alert">${c(n.persian)}</p>`:``}${this.getAttribute(`show-rules`)===`false`?``:`<ul class="k-strength__rules">${I.map(([t,r])=>{let i=r(e);return`<li class="k-strength__rule"${i?` data-met=""`:``}>${i?k:`<svg viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="2.5" fill="currentColor"/></svg>`}<span>${c(t(n))}<span class="k-sr-only">${i?n.met:n.unmet}</span></span></li>`}).join(``)}</ul>`}</div>`}};L.observedAttributes=[`for`,`show-rules`];var R=class extends m{constructor(){super(...arguments),this.key=_(`kashi-text`),this.rendered=!1,this.valueSet=!1,this.text=``}connectedCallback(){!this.rendered&&!this.valueSet&&(this.text=this.getAttribute(`value`)??``),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.value=n??``:this.render())}get value(){return this.text}set value(e){this.valueSet=!0,this.text=String(e??``),this.rendered&&(this.control.value=this.text,this.paint())}focus(e){this.control?.focus(e)}render(){let e=this.key,t=this.getAttribute(`aria-label`),n=this.hasAttribute(`label`)?this.getAttribute(`label`):t?null:this.defaultLabel,i=this.getAttribute(`name`),a=`id="${e}" class="k-input__control" dir="auto"${i?` name="${c(i)}"`:``}${this.hasAttribute(`required`)?` required`:``}${this.hasAttribute(`disabled`)?` disabled`:``} placeholder="${c(this.getAttribute(`placeholder`)??``)}"${!n&&t?` aria-label="${c(t)}"`:``}`,o=this.multiline?`<div class="k-input k-input--textarea"><textarea ${a} rows="${Number(this.getAttribute(`rows`))||4}"></textarea></div>`:`<div class="k-input"><input ${a}></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,h({id:e,label:n,required:this.hasAttribute(`required`),control:o})),this.control=this.querySelector(`.k-input__control`),this.control.value=this.text,this.control.addEventListener(`input`,()=>{this.text=this.control.value,this.paint(),r(this,`kashi-change`,{value:this.text})}),this.rendered=!0,this.paint()}paint(){let e=this.querySelector(`:scope > .k-field`);n(e,this.control,this.key,this.getAttribute(`error`),null);let t=this.hint();if(e.querySelector(`.k-field__hint-row[data-extra]`)?.remove(),t){e.insertAdjacentHTML(`beforeend`,`<div class="k-field__hint-row" data-extra><div class="k-field__hints"><p class="k-hint" id="${this.key}-hint">${t}</p></div></div>`);let n=(this.control.getAttribute(`aria-describedby`)??``).split(` `).filter(Boolean);this.control.setAttribute(`aria-describedby`,[...n,`${this.key}-hint`].join(` `))}}replace(e){this.text=e,this.control.value=e,this.paint(),this.control.focus(),r(this,`kashi-change`,{value:e})}};const z=[`arabic`,`zwnj`,`punctuation`,`digits`,`spacing`];var B=class extends R{constructor(){super(...arguments),this.multiline=!0}get defaultLabel(){return d().persianInput.text}render(){super.render(),this.control.addEventListener(`blur`,()=>{let e=this.result();o(this,`fix-on-blur`)&&e.count&&this.replace(e.text)}),this.addEventListener(`click`,e=>{e.target.closest(`[data-fix]`)&&this.replace(this.result().text)})}result(){return b(this.text,{digits:this.getAttribute(`fix-digits`)!==`false`})}hint(){if(!this.text.trim())return this.getAttribute(`hint`)?c(this.getAttribute(`hint`)):null;let e=this.result();if(!e.count)return`<span class="k-textfix" data-state="clean"><span class="k-textfix__text">${c(d().textFix.clean)}</span></span>`;let t=d().textFix,n=z.filter(t=>e.fixes[t]).map(n=>`${l(this,e.fixes[n])} ${t[n]}`).join(d().common.list);return`<span class="k-textfix" data-state="fix"><span class="k-textfix__text">${c(t.count(l(this,e.count),n))}</span><button type="button" class="k-btn k-btn--tertiary k-btn--xs" data-fix>${c(t.fix)}</button></span>`}};B.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`required`,`disabled`,`name`,`value`,`rows`,`fix-on-blur`,`fix-digits`,`aria-label`];var V=class extends R{constructor(){super(...arguments),this.multiline=!1}get defaultLabel(){return d().persianInput.text}render(){super.render(),this.addEventListener(`click`,e=>{e.target.closest(`[data-fix]`)&&this.replace(y(this.text))})}hint(){let e=this.text,t=/[a-z]/i.test(e)&&!/[؀-ۿ]/.test(e);return(this.getAttribute(`suggest`)===`always`?t:v(e))?`<span class="k-kbfix" role="status">${c(d().keyboardFix.before)} <button type="button" class="k-kbfix__btn" data-fix>«${c(y(e))}»</button>${i()===`en`?``:` `}${c(d().keyboardFix.after)}</span>`:this.getAttribute(`hint`)?c(this.getAttribute(`hint`)):null}};V.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`required`,`disabled`,`name`,`value`,`suggest`,`aria-label`];const H=e=>e.hours*60+e.minutes,U=e=>({hours:Math.floor(e/60),minutes:e%60});var W=class extends m{constructor(){super(...arguments),this.current=null,this.invalid=!1,this.valueSet=!1,this.rendered=!1,this.key=_(`kashi-time`)}connectedCallback(){!this.rendered&&!this.valueSet&&(this.current=this.normal(this.getAttribute(`value`))),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.value=n??``:this.render())}get value(){return this.current??``}set value(e){this.valueSet=!0,this.current=this.normal(e),this.invalid=!1,this.rendered&&this.paint()}normal(e){let t=e?x(e):null;return t?S(t):null}show(e){return e?p(this)===`latin`?e:t(e):``}get lo(){let e=x(this.getAttribute(`min`)??``);return e?H(e):0}get hi(){let e=x(this.getAttribute(`max`)??``);return e?H(e):1439}render(){let e=this.key,t=this.getAttribute(`aria-label`),n=this.hasAttribute(`label`)?this.getAttribute(`label`):t?null:d().persianInput.time,r=p(this)===`fa`,i=`<div class="k-input"><input id="${e}" class="k-input__control" type="text" inputmode="numeric" dir="ltr" autocomplete="off" placeholder="${c(this.getAttribute(`placeholder`)??(r?`۰۹:۳۰`:`09:30`))}"${this.hasAttribute(`required`)?` required`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${!n&&t?` aria-label="${c(t)}"`:``}><span class="k-input__addon"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="10" cy="10" r="7"/><path d="M10 6v4l2.5 2"/></svg></span></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,h({id:e,label:n,required:this.hasAttribute(`required`),control:i})),this.input=this.querySelector(`input.k-input__control`),this.input.addEventListener(`blur`,()=>this.commitText()),this.input.addEventListener(`keydown`,e=>{if(e.key===`Enter`&&this.commitText(),e.key!==`ArrowUp`&&e.key!==`ArrowDown`)return;e.preventDefault();let t=Number(this.getAttribute(`step`))||15,n=x(this.input.value)??x(this.current??``)??U(this.lo),r=H(n),i=e.key===`ArrowUp`?Math.floor(r/t)*t+t:Math.ceil(r/t)*t-t;this.commit(U(Math.min(this.hi,Math.max(this.lo,i))))}),this.rendered=!0,this.paint()}commitText(){let e=this.input.value.trim();if(!e)return this.commit(null);let t=x(e);if(!t)this.invalid=`format`;else if(H(t)<this.lo||H(t)>this.hi)this.invalid=`range`;else return this.commit(t);this.paint(!1)}commit(e){let t=e?S(e):null,n=t!==this.current;this.current=t,this.invalid=!1,this.paint(),n&&r(this,`kashi-change`,{value:t??``})}paint(e=!0){e&&(this.input.value=this.show(this.current));let t=this.invalid===`range`?d().invalid.timeRange(this.show(S(U(this.lo))),this.show(S(U(this.hi)))):this.invalid?d().invalid.time:null;this.input.setCustomValidity(t??``),n(this.querySelector(`:scope > .k-field`),this.input,this.key,this.getAttribute(`error`)||t,this.getAttribute(`hint`)),g(this,this.getAttribute(`name`),this.current??``)}};W.observedAttributes=[`label`,`hint`,`error`,`value`,`min`,`max`,`step`,`digits`,`required`,`disabled`,`name`,`placeholder`,`aria-label`];const G={first:``,letter:``,middle:``,region:``};var K=class extends m{constructor(){super(...arguments),this.plate={...G},this.touched=!1,this.valueSet=!1,this.rendered=!1,this.key=_(`kashi-plate`)}connectedCallback(){!this.rendered&&!this.valueSet&&(this.plate=this.parse(this.getAttribute(`value`))),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.value=this.parse(n):this.render())}parse(t){let[n=``,r=``,i=``,a=``]=(t??``).split(`-`);return{first:e(n),letter:r,middle:e(i),region:e(a)}}get value(){return{...this.plate}}set value(e){this.valueSet=!0,this.plate={...G,...e},this.rendered&&this.render()}get valid(){return D(this.plate)}render(){let n=this.key,i=this.plate,a=this.hasAttribute(`disabled`)?` disabled`:``,o=(e,r,o,s=``,c=!1)=>`<input${c?` id="${n}-first"`:``} class="k-plate__seg ${s}" data-key="${e}" data-len="${r}" inputmode="numeric" autocomplete="off" aria-label="${o}" placeholder="${t(`0`.repeat(r))}" value="${t(i[e])}"${a}>`,s=d().plate,l=this.getAttribute(`label`)??s.label,u=`<div class="k-plate" role="group" aria-label="${c(l)}" data-type="${E(i.letter)}"><span class="k-plate__flag" aria-hidden="true"><span class="k-plate__flag-colors"></span>I.R.<br>IRAN</span>${o(`first`,2,s.first,``,!0)}<select class="k-plate__letter" data-key="letter" aria-label="${c(s.letter)}"${a}><option value="">–</option>${w.map(e=>`<option value="${e}"${e===i.letter?` selected`:``}>${e===`ه`?`هـ`:e}</option>`).join(``)}</select>${o(`middle`,3,s.middle,`k-plate__seg--3`)}<span class="k-plate__region"><span class="k-plate__region-label" aria-hidden="true">ایران</span>${o(`region`,2,s.region)}</span></div><span class="k-sr-only" aria-live="polite"></span>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,h({id:`${n}-first`,label:l,control:u}));let f=[...this.querySelectorAll(`[data-key]`)];f.forEach((n,i)=>{n.addEventListener(n instanceof HTMLSelectElement?`change`:`input`,()=>{let a=n.dataset.key;if(n instanceof HTMLSelectElement)this.plate.letter=n.value,n.value&&f[i+1]?.focus();else{let r=Number(n.dataset.len),o=e(n.value);a===`middle`&&o.length>r&&(this.plate.region=(this.plate.region+o.slice(r)).slice(0,2)),this.plate[a]=o.slice(0,r),n.value=t(this.plate[a]),this.plate[a].length===r&&f[i+1]?.focus()}this.paint(),r(this,`kashi-change`,{value:this.value,valid:this.valid})}),n.addEventListener(`keydown`,e=>{e.key===`Backspace`&&!n.value&&f[i-1]?.focus()})});let p=this.querySelector(`.k-plate`);p.addEventListener(`focusout`,e=>{p.contains(e.relatedTarget)||(this.touched=!0,this.paint())}),this.rendered=!0,this.paint()}paint(){let e=this.plate,r=this.querySelector(`.k-plate`),i=this.querySelector(`[data-key="region"]`);i.value!==t(e.region)&&(i.value=t(e.region)),r.dataset.type=E(e.letter);let a=e.first.length===2&&!!e.letter&&e.middle.length===3&&e.region.length===2,o=(this.touched||a)&&Object.values(e).some(Boolean)&&!this.valid,s=this.getAttribute(`error`)||(o?d().invalid.plate:null);r.toggleAttribute(`data-invalid`,!!s),n(this.querySelector(`:scope > .k-field`),r,this.key,s,this.getAttribute(`hint`)),this.querySelector(`.k-field > .k-sr-only`).textContent=this.valid?O(e):``;let l=this.getAttribute(`name`);if(this.querySelectorAll(`:scope > input[type=hidden]`).forEach(e=>e.remove()),l)for(let t of[`first`,`letter`,`middle`,`region`])this.insertAdjacentHTML(`beforeend`,`<input type="hidden" name="${c(`${l}_${t}`)}" value="${c(e[t])}">`)}};K.observedAttributes=[`label`,`hint`,`error`,`name`,`disabled`,`value`];var q=class extends m{constructor(){super(...arguments),this.text=``,this.editing=!1,this.valueSet=!1,this.rendered=!1}connectedCallback(){!this.rendered&&!this.valueSet&&(this.text=this.getAttribute(`value`)??this.textContent?.trim()??``),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`&&(this.text=n??``),this.editing||this.render())}get value(){return this.text}set value(e){this.valueSet=!0,this.text=String(e??``),this.rendered&&!this.editing&&this.render()}render(e=!1){let t=this.getAttribute(`label`)??d().persianInput.text;this.rendered=!0,this.editing=!1,this.innerHTML=`<span class="k-inline-edit"><button type="button" class="k-inline-edit__view" aria-label="${c(`${t}: ${this.text||d().inlineEdit.empty}${d().common.list}${d().common.edit}`)}">${this.text?c(this.text):`<span class="k-inline-edit__placeholder">${c(this.getAttribute(`placeholder`)??d().inlineEdit.empty)}</span>`}<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m13.5 3.5 3 3L7 16H4v-3Z"/></svg></button></span>`;let n=this.querySelector(`button`);n.addEventListener(`click`,()=>this.edit()),e&&n.focus()}edit(e,t=this.text){this.editing=!0;let n=this.getAttribute(`label`)??d().persianInput.text,r=_(`kashi-ie-err`);this.innerHTML=`<span class="k-inline-edit"><span class="k-field" style="gap: 4px"><span class="k-input"${e?` data-state="invalid"`:``}><input class="k-input__control" aria-label="${c(n)}" placeholder="${c(this.getAttribute(`placeholder`)??``)}"${e?` aria-invalid="true" aria-describedby="${r}"`:``}></span>${e?`<span class="k-hint k-hint--error" id="${r}">${c(e)}</span>`:``}</span><span class="k-inline-edit__actions"><button type="button" class="k-btn k-btn--primary k-btn--icon k-btn--sm" data-save aria-label="${c(d().common.save)}">${k}</button><button type="button" class="k-btn k-btn--secondary k-btn--icon k-btn--sm" data-cancel aria-label="${c(d().common.cancel)}">${A}</button></span></span>`;let i=this.querySelector(`input`);i.value=t,i.focus(),i.select(),i.addEventListener(`keydown`,e=>{e.key===`Enter`?(e.preventDefault(),this.commit(i.value)):e.key===`Escape`&&(e.preventDefault(),this.render(!0))}),this.querySelector(`[data-save]`).addEventListener(`click`,()=>this.commit(i.value)),this.querySelector(`[data-cancel]`).addEventListener(`click`,()=>this.render(!0))}async commit(e){let t=e.trim(),n=this.validate?.(t);if(n)return this.edit(n,e);if(t===this.text)return this.render(!0);let i=this.text,a=null;if(r(this,`kashi-save`,{value:t,wait:e=>a=e}),this.text=t,a){this.querySelector(`[data-save]`)?.setAttribute(`aria-busy`,`true`);try{await a}catch{return this.text=i,this.edit(d().inlineEdit.failed,e)}}this.render(!0),r(this,`kashi-change`,{value:t})}};q.observedAttributes=[`value`,`label`,`placeholder`],u(`kashi-multi-select`,N,`block`),u(`kashi-slider`,P,`block`),u(`kashi-chip-group`,F),u(`kashi-password-strength`,L,`block`),u(`kashi-persian-textarea`,B,`block`),u(`kashi-keyboard-fix`,V,`block`),u(`kashi-time-input`,W,`block`),u(`kashi-plate-input`,K,`block`),u(`kashi-inline-edit`,q);export{F as KashiChipGroup,q as KashiInlineEdit,V as KashiKeyboardFix,N as KashiMultiSelect,L as KashiPasswordStrength,B as KashiPersianTextarea,K as KashiPlateInput,P as KashiSlider,W as KashiTimeInput};
@@ -0,0 +1,14 @@
1
+ import{A as e,C as t,a as n,c as r,d as i,i as a,l as o,m as s,o as c,p as l,s as u,t as d}from"./base-BqFAMlwG.js";import{t as f}from"./holidays-DgmHlqJX.js";import{c as p,l as m,p as h}from"./parts-5fVaWtRe.js";const g=e=>typeof e==`string`&&/^\d{4}-\d{2}-\d{2}$/.test(e)?new Date(+e.slice(0,4),e.slice(5,7)-1,+e.slice(8,10)):h(e),_=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),v=(e,t)=>new Date(e.getFullYear(),e.getMonth(),e.getDate()+t),y=(e,t)=>Math.round((_(t).getTime()-_(e).getTime())/864e5);var b=class extends d{constructor(){super(...arguments),this.data=null,this.drag=null}connectedCallback(){this.render()}attributeChangedCallback(e,t,n){t!==n&&(e===`tasks`&&(this.data=null),this.isConnected&&this.render())}get tasks(){return this.data?this.data:this.norm(m(this,`tasks`,[]))}set tasks(e){this.data=this.norm(e??[]),this.isConnected&&this.render()}norm(e){return e.map(e=>({id:String(e.id),name:e.name,start:_(g(e.start)??/* @__PURE__ */ new Date),end:_(g(e.end)??g(e.start)??/* @__PURE__ */ new Date),progress:Math.max(0,Math.min(100,e.progress??0)),color:e.color,dependsOn:e.dependsOn??[],milestone:!!e.milestone}))}render(){let r=l().gantt,c=this.tasks;this.data=c;let d=_(g(this.getAttribute(`today`))??/* @__PURE__ */ new Date),p=g(this.getAttribute(`from`)),m=g(this.getAttribute(`to`)),h=p?_(p):v(new Date(Math.min(...c.map(e=>e.start.getTime()),d.getTime())),-3),b=m?_(m):v(new Date(Math.max(...c.map(e=>e.end.getTime()),d.getTime())),5),x=y(h,b)+1,S=a(this,`holidays`,!0),C=a(this,`editable`),{months:w}=n(),T=e=>t(e,{locale:i(),digits:u(this)}),E=this.getAttribute(`label`)??r.label,D=``,O=[],k=[],A=y(h,d);for(let t=0;t<x;t++){let n=v(h,t),r=e(n),i=n.getDay()===5||S&&!!f(n);i&&O.push(t);let a=`${r.jy}-${r.jm}`,o=k[k.length-1];o?.key===a?o.span++:k.push({key:a,label:`${w[r.jm-1]} ${s(this,r.jy)}`,span:1}),D+=`<span class="k-gantt__day"${i?` data-off`:``}${t===A?` data-today`:``}${r.jd===1?` data-first`:``}>${s(this,r.jd)}</span>`}let j=k.map(e=>`<span class="k-gantt__month" style="grid-column: span ${e.span}">${o(e.label)}</span>`).join(``),M=new Map(c.map((e,t)=>[e.id,{t:e,i:t}])),N=O.map(e=>`<span class="k-gantt__off" style="grid-column: ${e+1}" aria-hidden="true"></span>`).join(``),P=c.map((e,t)=>{let n=y(h,e.start),i=e.milestone?1:y(e.start,e.end)+1,a=e.dependsOn.map(e=>M.get(e)).filter(Boolean),c=[r.bar(e.name,T(e.start),T(e.end),s(this,e.progress)),...a.map(e=>r.dependsOn(e.t.name))].join(l().common.comma),u=a.map(e=>{let r=y(h,e.t.end)+1,i=e.i-t;return`<span class="k-gantt__dep" aria-hidden="true"${r>n?` data-backward`:``}${i>0?` data-below`:``} style="--from:${r};--to:${n};--rows:${Math.abs(i)}"></span>`}).join(``);return`<div class="k-gantt__row" role="row" aria-rowindex="${t+2}">
2
+ <div class="k-gantt__name" role="rowheader"><span class="k-gantt__dot"${e.color?` style="background:${o(e.color)}"`:``} aria-hidden="true"></span><span class="k-gantt__label">${o(e.name)}</span><span class="k-gantt__len">${o(r.days(s(this,i)))}</span></div>
3
+ <div class="k-gantt__track" role="cell">${N}${u}<button type="button" class="k-gantt__bar" data-id="${o(e.id)}"${e.milestone?` data-milestone`:``}${e.progress>=100?` data-done`:``} style="--start:${n};--len:${i};--progress:${e.progress}%${e.color?`;--k-gantt-color:${o(e.color)}`:``}" aria-label="${o(c)}"${C?` aria-describedby="${this.id||`k`}-gantt-hint"`:``}>${e.milestone?``:`<span class="k-gantt__fill" aria-hidden="true"></span><span class="k-gantt__text" aria-hidden="true">${o(e.name)}</span>${C?`<span class="k-gantt__grip" aria-hidden="true"></span>`:``}`}</button></div>
4
+ </div>`}).join(``);this.innerHTML=`<div class="k-gantt" style="--k-gantt-days:${x}">
5
+ <div class="k-gantt__scroll" role="region" aria-label="${o(E)}" tabindex="0">
6
+ <div class="k-gantt__grid" role="table" aria-label="${o(E)}" aria-rowcount="${c.length+1}">
7
+ <div class="k-gantt__head" role="row"><div class="k-gantt__corner" role="columnheader">${o(this.getAttribute(`task-header`)??r.task)}</div><div class="k-gantt__timehead" role="columnheader" aria-label="${o(`${T(h)} – ${T(b)}`)}"><div class="k-gantt__months" aria-hidden="true">${j}</div><div class="k-gantt__days" aria-hidden="true">${D}</div></div></div>
8
+ ${P}
9
+ ${A>=0&&A<x?`<span class="k-gantt__now" style="--today:${A}" aria-hidden="true"><span>${o(r.today)}</span></span>`:``}
10
+ </div>
11
+ </div>
12
+ ${C?`<span class="k-sr-only" id="${this.id||`k`}-gantt-hint">${o(r.hint)}</span>`:``}
13
+ <span class="k-sr-only" aria-live="polite"></span>
14
+ </div>`,C&&this.wire()}change(e,n,a){let o=this.data.find(t=>t.id===e);if(!o)return;a<n&&(a=n),o.start=n,o.end=a;let s=e=>t(e,{locale:i(),digits:u(this)}),c=l().gantt.moved(o.name,s(n),s(a));this.render(),[...this.querySelectorAll(`.k-gantt__bar`)].find(t=>t.dataset.id===e)?.focus(),this.querySelector(`.k-gantt > [aria-live]`).textContent=c,r(this,`kashi-change`,{id:e,start:n,end:a})}wire(){this.querySelectorAll(`.k-gantt__bar`).forEach(e=>{let t=e.dataset.id,n=()=>this.data.find(e=>e.id===t);e.addEventListener(`keydown`,r=>{if(r.key!==`ArrowLeft`&&r.key!==`ArrowRight`)return;r.preventDefault();let i=(r.key===`ArrowLeft`?1:-1)*(p(e)?1:-1),a=n();r.shiftKey&&!a.milestone?this.change(t,a.start,v(a.end,i)):this.change(t,v(a.start,i),v(a.end,i))}),e.addEventListener(`pointerdown`,r=>{if(r.button!==0)return;e.setPointerCapture(r.pointerId);let i=e.getBoundingClientRect(),a=p(e),o=n(),s=a?r.clientX-i.left:i.right-r.clientX,c=o.milestone?1:y(o.start,o.end)+1;this.drag={id:t,x:r.clientX,kind:!o.milestone&&s<10?`end`:`move`,start:o.start,end:o.end,px:i.width/c,dir:a?-1:1,moved:!1,delta:0}}),e.addEventListener(`pointermove`,n=>{let r=this.drag;if(!r||r.id!==t||(r.delta=Math.round((n.clientX-r.x)*r.dir/r.px),r.delta&&(r.moved=!0),!r.moved))return;e.setAttribute(`data-dragging`,``);let i=r.kind===`move`?v(r.start,r.delta):r.start,a=r.kind===`move`?v(r.end,r.delta):v(r.end,Math.max(r.delta,-y(r.start,r.end)));e.style.transform=`translateX(${(r.kind===`move`?r.delta:0)*r.px*r.dir}px)`,r.kind===`end`&&(e.style.inlineSize=`calc(${y(i,a)+1} * var(--_day) - 4px)`)}),e.addEventListener(`pointerup`,()=>{let e=this.drag;if(this.drag=null,!e?.moved)return;let n=e.kind===`move`?v(e.start,e.delta):e.start,r=e.kind===`move`?v(e.end,e.delta):v(e.end,Math.max(e.delta,-y(e.start,e.end)));this.change(t,n,r)}),e.addEventListener(`pointercancel`,()=>{this.drag=null,this.render()})})}};b.observedAttributes=[`tasks`,`from`,`to`,`today`,`editable`,`holidays`,`label`,`task-header`],c(`kashi-gantt`,b,`block`);export{b as KashiGantt};
@@ -1 +1 @@
1
- import{A as e}from"./base-D4tCOysh.js";const t={"1-1":`عید نوروز`,"1-2":`عید نوروز`,"1-3":`عید نوروز`,"1-4":`عید نوروز`,"1-12":`روز جمهوری اسلامی`,"1-13":`روز طبیعت`,"3-14":`رحلت امام خمینی`,"3-15":`قیام ۱۵ خرداد`,"11-22":`پیروزی انقلاب اسلامی`,"12-29":`ملی شدن صنعت نفت`},n={"1-1":`Nowruz`,"1-2":`Nowruz`,"1-3":`Nowruz`,"1-4":`Nowruz`,"1-12":`Islamic Republic Day`,"1-13":`Nature Day`,"3-14":`Death of Imam Khomeini`,"3-15":`15 Khordad Uprising`,"11-22":`Islamic Revolution Victory Day`,"12-29":`Oil Nationalization Day`};function r(r,{extra:i={},friday:a=!0,locale:o=`fa`}={}){let{jm:s,jd:c}=e(r),l=`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,`0`)}-${String(r.getDate()).padStart(2,`0`)}`,u=(o===`en`?n:t)[`${s}-${c}`];return i[l]??i[`${s}-${c}`]??u??(a&&r.getDay()===5?o===`en`?`Friday`:`جمعه`:null)}export{r as t};
1
+ import{A as e}from"./base-BqFAMlwG.js";const t={"1-1":`عید نوروز`,"1-2":`عید نوروز`,"1-3":`عید نوروز`,"1-4":`عید نوروز`,"1-12":`روز جمهوری اسلامی`,"1-13":`روز طبیعت`,"3-14":`رحلت امام خمینی`,"3-15":`قیام ۱۵ خرداد`,"11-22":`پیروزی انقلاب اسلامی`,"12-29":`ملی شدن صنعت نفت`},n={"1-1":`Nowruz`,"1-2":`Nowruz`,"1-3":`Nowruz`,"1-4":`Nowruz`,"1-12":`Islamic Republic Day`,"1-13":`Nature Day`,"3-14":`Death of Imam Khomeini`,"3-15":`15 Khordad Uprising`,"11-22":`Islamic Revolution Victory Day`,"12-29":`Oil Nationalization Day`};function r(r,{extra:i={},friday:a=!0,locale:o=`fa`}={}){let{jm:s,jd:c}=e(r),l=`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,`0`)}-${String(r.getDate()).padStart(2,`0`)}`,u=(o===`en`?n:t)[`${s}-${c}`];return i[l]??i[`${s}-${c}`]??u??(a&&r.getDay()===5?o===`en`?`Friday`:`جمعه`:null)}export{r as t};
@@ -1 +1 @@
1
- import{E as e,P as t,S as n,a as r,c as i,d as a,i as o,l as s,m as c,o as l,p as u,r as d,s as f,t as p,v as m,x as h,y as g}from"./base-D4tCOysh.js";import{n as _}from"./time-CwOYrtK-.js";import{p as v,s as y}from"./parts-5fVaWtRe.js";import"./forms-DgRiYmdV.js";const b=e=>{let t=_(e);return t?t.hours*60+t.minutes:NaN};function x(){return Array.from({length:7},(e,t)=>t===6?{open:!1,ranges:[]}:{open:!0,ranges:[{from:`09:00`,to:t===5?`13:00`:`17:00`}]})}function S(e){if(!e.open)return[];let t=/* @__PURE__ */ new Set;return e.ranges.forEach((n,r)=>{let i=b(n.from),a=b(n.to);i<a||t.add(r),e.ranges.forEach((e,n)=>{n>r&&b(e.from)<a&&i<b(e.to)&&t.add(r).add(n)})}),[...t].sort()}function C(t,n=/* @__PURE__ */ new Date){let r=e(n),i=n.getHours()*60+n.getMinutes(),a=t[r];if(a?.open&&a.ranges.some(e=>b(e.from)<b(e.to)?i>=b(e.from)&&i<b(e.to):i>=b(e.from)))return!0;let o=t[(r+6)%7];return!!o?.open&&o.ranges.some(e=>b(e.from)>b(e.to)&&i<b(e.to))}function w(e,{locale:r=`fa`}={}){let i=r===`en`,a=i?n:h,o=e=>i?e:t(e),s=e=>e.open&&e.ranges.length?e.ranges.map(e=>`${e.from}-${e.to}`).join(`,`):`closed`,c=e=>s(e)===`closed`?i?`closed`:`تعطیل`:e.ranges.map(e=>o(`${e.from}${i?`–`:` تا `}${e.to}`)).join(i?`, `:` و `),l=[];for(let t=0;t<7;){let n=t;for(;n+1<7&&s(e[n+1])===s(e[t]);)n++;let r=t===n?a[t]:`${a[t]}${i?`–`:` تا `}${a[n]}`;l.push(`${r}${i?`: `:` `}${c(e[t])}`),t=n+1}return l.join(i?`; `:`؛ `)}const T=y(`<path d="M6 6l8 8M14 6l-8 8"/>`),E=y(`<path d="M10 5v10M5 10h10"/>`),D=e=>e.map(e=>({open:e.open,ranges:e.ranges.map(e=>({...e}))}));var O=class extends p{constructor(){super(...arguments),this.week=null,this.root=null,this.key=g(`kashi-hours`)}connectedCallback(){d(()=>{this.isConnected&&(this.root||(this.week??=this.parse(this.getAttribute(`value`)),this.root=document.createElement(`fieldset`),this.root.className=`k-hours`,this.replaceChildren(this.root),this.root.addEventListener(`change`,e=>this.onToggle(e)),this.root.addEventListener(`kashi-change`,e=>this.onTime(e)),this.root.addEventListener(`click`,e=>this.onClick(e))),this.render())})}attributeChangedCallback(e,t,n){t!==n&&(e===`value`&&(this.week=this.parse(n)),this.root&&this.render())}get value(){return D(this.week??this.parse(this.getAttribute(`value`)))}set value(e){this.week=Array.isArray(e)&&e.length===7?D(e):x(),this.root&&this.render()}get valid(){return this.value.every(e=>S(e).length===0)}parse(e){if(!e)return x();try{let t=JSON.parse(e);return Array.isArray(t)&&t.length===7?t:x()}catch{return x()}}commit(e,t){this.week=e,this.render(t),i(this,`kashi-change`,{value:this.value,valid:this.valid})}dayOf(e){return Number(e.closest(`[data-day]`)?.dataset.day)}onToggle(e){let t=e.target;if(!t.matches(`.k-switch`))return;e.stopPropagation();let n=this.dayOf(t),r=this.value;r[n]={open:t.checked,ranges:t.checked&&!r[n].ranges.length?[{from:`09:00`,to:`17:00`}]:r[n].ranges},this.commit(r,`[data-day="${n}"] .k-switch`)}onTime(e){let t=e.target;if(t===this||!t.matches(`kashi-time-input`)||(e.stopPropagation(),!e.detail?.value))return;let n=this.dayOf(t),r=Number(t.dataset.range),a=this.value;a[n].ranges[r]={...a[n].ranges[r],[t.dataset.part]:e.detail.value},this.week=a,this.paintState(),i(this,`kashi-change`,{value:this.value,valid:this.valid})}onClick(e){let t=e.target.closest(`button[data-act]`);if(!t)return;let n=this.value,r=this.dayOf(t);if(t.dataset.act===`remove`)n[r].ranges.splice(Number(t.dataset.range),1),this.commit(n,`[data-day="${r}"] [data-act=add], [data-day="${r}"] .k-switch`);else if(t.dataset.act===`add`){let e=n[r].ranges[n[r].ranges.length-1]?.to??`09:00`,t=Math.min(23,Number(e.slice(0,2))+1);n[r].ranges.push({from:`${String(t).padStart(2,`0`)}:00`,to:`${String(Math.min(23,t+3)).padStart(2,`0`)}:00`}),this.commit(n,`[data-day="${r}"] kashi-time-input[data-range="${n[r].ranges.length-1}"][data-part=from]`)}else if(t.dataset.act===`copy`){let e=n.find(e=>e.open&&e.ranges.length);e&&this.commit(n.map(t=>t.open?{open:!0,ranges:e.ranges.map(e=>({...e}))}:t),`.k-hours__copy`)}}render(e){let t=u(),n=t.businessHours,{weekdays:i}=r(),a=this.root,l=this.week,d=this.getAttribute(`step`)??`30`,p=Number(this.getAttribute(`max-ranges`))||3,m=f(this);a.disabled=o(this,`disabled`),a.setAttribute(`aria-labelledby`,`${this.key}-legend`),a.innerHTML=`<legend id="${this.key}-legend" class="k-hours__legend">${s(this.getAttribute(`label`)??n.label)}</legend><div class="k-hours__days">${l.map((e,r)=>{let a=`${this.key}-e${r}`,o=e.ranges.map((a,o)=>{let l=n.rangeOf(i[r],c(this,o+1)),u=e=>`<kashi-time-input data-part="${e}" data-range="${o}" value="${s(a[e])}" step="${s(d)}" digits="${m}" aria-label="${s(`${l}${t.common.list}${e===`from`?n.from:n.to}`)}"></kashi-time-input>`;return`<div class="k-hours__range" role="group" aria-label="${s(l)}">${u(`from`)}<span class="k-hours__sep" aria-hidden="true">${s(n.to)}</span>${u(`to`)}${e.ranges.length>1?`<button type="button" class="k-hours__icon" data-act="remove" data-range="${o}" aria-label="${s(`${n.removeRange}${t.common.list}${l}`)}">${T}</button>`:``}</div>`}).join(``);return`<div class="k-hours__day" data-day="${r}"${e.open?` data-open`:``}><label class="k-hours__toggle"><input type="checkbox" role="switch" class="k-switch k-switch--sm"${e.open?` checked`:``}><span class="k-hours__name">${s(i[r])}</span></label><div class="k-hours__body"><div class="k-hours__inner">${e.open?`${o}${e.ranges.length<p?`<button type="button" class="k-hours__add" data-act="add">${E}${s(n.addRange)}</button>`:``}<p class="k-hint k-hint--error k-hours__error" id="${a}" hidden>${s(n.invalid)}</p>`:`<span class="k-hours__closed">${s(n.closed)}</span>`}</div></div></div>`}).join(``)}</div>${this.getAttribute(`summary`)===`false`?``:`<div class="k-hours__foot"><span class="k-hours__status"><span class="k-hours__dot" aria-hidden="true"></span><span></span></span><p class="k-hours__summary"></p><button type="button" class="k-btn k-btn--tertiary k-btn--sm k-hours__copy" data-act="copy">${s(n.copyAll)}</button></div>`}`,this.paintState(),e&&a.querySelector(e)?.focus()}paintState(){let e=u().businessHours,t=this.root,n=this.week;n.forEach((e,n)=>{let r=S(e),i=t.querySelector(`[data-day="${n}"]`);i.toggleAttribute(`data-invalid`,r.length>0);let a=i.querySelector(`.k-hours__error`);a&&(a.hidden=!r.length),i.querySelectorAll(`.k-hours__range`).forEach((e,t)=>e.toggleAttribute(`data-invalid`,r.includes(t))),i.querySelectorAll(`kashi-time-input`).forEach(e=>{let t=e.querySelector(`input`);t&&r.length&&t.setAttribute(`aria-describedby`,`${this.key}-e${n}`)})});let r=t.querySelector(`.k-hours__foot`);if(r){let t=C(n,v(this.getAttribute(`now`))??/* @__PURE__ */ new Date),i=r.querySelector(`.k-hours__status`);i.toggleAttribute(`data-open`,t),i.lastElementChild.textContent=t?e.openNow:e.closedNow,r.querySelector(`.k-hours__summary`).textContent=w(n,{locale:a()}),r.querySelector(`.k-hours__copy`).hidden=!n.some(e=>e.open&&e.ranges.length)}m(this,this.getAttribute(`name`),this.valid?JSON.stringify(n):``)}};O.observedAttributes=[`value`,`label`,`step`,`max-ranges`,`summary`,`now`,`name`,`digits`,`disabled`],l(`kashi-business-hours`,O,`block`);export{O as KashiBusinessHours};
1
+ import{E as e,P as t,S as n,a as r,c as i,d as a,i as o,l as s,m as c,o as l,p as u,r as d,s as f,t as p,v as m,x as h,y as g}from"./base-BqFAMlwG.js";import{n as _}from"./time-oyKIQ2bk.js";import{p as v,s as y}from"./parts-5fVaWtRe.js";import"./forms-CurTYl2V.js";const b=e=>{let t=_(e);return t?t.hours*60+t.minutes:NaN};function x(){return Array.from({length:7},(e,t)=>t===6?{open:!1,ranges:[]}:{open:!0,ranges:[{from:`09:00`,to:t===5?`13:00`:`17:00`}]})}function S(e){if(!e.open)return[];let t=/* @__PURE__ */ new Set;return e.ranges.forEach((n,r)=>{let i=b(n.from),a=b(n.to);i<a||t.add(r),e.ranges.forEach((e,n)=>{n>r&&b(e.from)<a&&i<b(e.to)&&t.add(r).add(n)})}),[...t].sort()}function C(t,n=/* @__PURE__ */ new Date){let r=e(n),i=n.getHours()*60+n.getMinutes(),a=t[r];if(a?.open&&a.ranges.some(e=>b(e.from)<b(e.to)?i>=b(e.from)&&i<b(e.to):i>=b(e.from)))return!0;let o=t[(r+6)%7];return!!o?.open&&o.ranges.some(e=>b(e.from)>b(e.to)&&i<b(e.to))}function w(e,{locale:r=`fa`}={}){let i=r===`en`,a=i?n:h,o=e=>i?e:t(e),s=e=>e.open&&e.ranges.length?e.ranges.map(e=>`${e.from}-${e.to}`).join(`,`):`closed`,c=e=>s(e)===`closed`?i?`closed`:`تعطیل`:e.ranges.map(e=>o(`${e.from}${i?`–`:` تا `}${e.to}`)).join(i?`, `:` و `),l=[];for(let t=0;t<7;){let n=t;for(;n+1<7&&s(e[n+1])===s(e[t]);)n++;let r=t===n?a[t]:`${a[t]}${i?`–`:` تا `}${a[n]}`;l.push(`${r}${i?`: `:` `}${c(e[t])}`),t=n+1}return l.join(i?`; `:`؛ `)}const T=y(`<path d="M6 6l8 8M14 6l-8 8"/>`),E=y(`<path d="M10 5v10M5 10h10"/>`),D=e=>e.map(e=>({open:e.open,ranges:e.ranges.map(e=>({...e}))}));var O=class extends p{constructor(){super(...arguments),this.week=null,this.root=null,this.key=g(`kashi-hours`)}connectedCallback(){d(()=>{this.isConnected&&(this.root||(this.week??=this.parse(this.getAttribute(`value`)),this.root=document.createElement(`fieldset`),this.root.className=`k-hours`,this.replaceChildren(this.root),this.root.addEventListener(`change`,e=>this.onToggle(e)),this.root.addEventListener(`kashi-change`,e=>this.onTime(e)),this.root.addEventListener(`click`,e=>this.onClick(e))),this.render())})}attributeChangedCallback(e,t,n){t!==n&&(e===`value`&&(this.week=this.parse(n)),this.root&&this.render())}get value(){return D(this.week??this.parse(this.getAttribute(`value`)))}set value(e){this.week=Array.isArray(e)&&e.length===7?D(e):x(),this.root&&this.render()}get valid(){return this.value.every(e=>S(e).length===0)}parse(e){if(!e)return x();try{let t=JSON.parse(e);return Array.isArray(t)&&t.length===7?t:x()}catch{return x()}}commit(e,t){this.week=e,this.render(t),i(this,`kashi-change`,{value:this.value,valid:this.valid})}dayOf(e){return Number(e.closest(`[data-day]`)?.dataset.day)}onToggle(e){let t=e.target;if(!t.matches(`.k-switch`))return;e.stopPropagation();let n=this.dayOf(t),r=this.value;r[n]={open:t.checked,ranges:t.checked&&!r[n].ranges.length?[{from:`09:00`,to:`17:00`}]:r[n].ranges},this.commit(r,`[data-day="${n}"] .k-switch`)}onTime(e){let t=e.target;if(t===this||!t.matches(`kashi-time-input`)||(e.stopPropagation(),!e.detail?.value))return;let n=this.dayOf(t),r=Number(t.dataset.range),a=this.value;a[n].ranges[r]={...a[n].ranges[r],[t.dataset.part]:e.detail.value},this.week=a,this.paintState(),i(this,`kashi-change`,{value:this.value,valid:this.valid})}onClick(e){let t=e.target.closest(`button[data-act]`);if(!t)return;let n=this.value,r=this.dayOf(t);if(t.dataset.act===`remove`)n[r].ranges.splice(Number(t.dataset.range),1),this.commit(n,`[data-day="${r}"] [data-act=add], [data-day="${r}"] .k-switch`);else if(t.dataset.act===`add`){let e=n[r].ranges[n[r].ranges.length-1]?.to??`09:00`,t=Math.min(23,Number(e.slice(0,2))+1);n[r].ranges.push({from:`${String(t).padStart(2,`0`)}:00`,to:`${String(Math.min(23,t+3)).padStart(2,`0`)}:00`}),this.commit(n,`[data-day="${r}"] kashi-time-input[data-range="${n[r].ranges.length-1}"][data-part=from]`)}else if(t.dataset.act===`copy`){let e=n.find(e=>e.open&&e.ranges.length);e&&this.commit(n.map(t=>t.open?{open:!0,ranges:e.ranges.map(e=>({...e}))}:t),`.k-hours__copy`)}}render(e){let t=u(),n=t.businessHours,{weekdays:i}=r(),a=this.root,l=this.week,d=this.getAttribute(`step`)??`30`,p=Number(this.getAttribute(`max-ranges`))||3,m=f(this);a.disabled=o(this,`disabled`),a.setAttribute(`aria-labelledby`,`${this.key}-legend`),a.innerHTML=`<legend id="${this.key}-legend" class="k-hours__legend">${s(this.getAttribute(`label`)??n.label)}</legend><div class="k-hours__days">${l.map((e,r)=>{let a=`${this.key}-e${r}`,o=e.ranges.map((a,o)=>{let l=n.rangeOf(i[r],c(this,o+1)),u=e=>`<kashi-time-input data-part="${e}" data-range="${o}" value="${s(a[e])}" step="${s(d)}" digits="${m}" aria-label="${s(`${l}${t.common.list}${e===`from`?n.from:n.to}`)}"></kashi-time-input>`;return`<div class="k-hours__range" role="group" aria-label="${s(l)}">${u(`from`)}<span class="k-hours__sep" aria-hidden="true">${s(n.to)}</span>${u(`to`)}${e.ranges.length>1?`<button type="button" class="k-hours__icon" data-act="remove" data-range="${o}" aria-label="${s(`${n.removeRange}${t.common.list}${l}`)}">${T}</button>`:``}</div>`}).join(``);return`<div class="k-hours__day" data-day="${r}"${e.open?` data-open`:``}><label class="k-hours__toggle"><input type="checkbox" role="switch" class="k-switch k-switch--sm"${e.open?` checked`:``}><span class="k-hours__name">${s(i[r])}</span></label><div class="k-hours__body"><div class="k-hours__inner">${e.open?`${o}${e.ranges.length<p?`<button type="button" class="k-hours__add" data-act="add">${E}${s(n.addRange)}</button>`:``}<p class="k-hint k-hint--error k-hours__error" id="${a}" hidden>${s(n.invalid)}</p>`:`<span class="k-hours__closed">${s(n.closed)}</span>`}</div></div></div>`}).join(``)}</div>${this.getAttribute(`summary`)===`false`?``:`<div class="k-hours__foot"><span class="k-hours__status"><span class="k-hours__dot" aria-hidden="true"></span><span></span></span><p class="k-hours__summary"></p><button type="button" class="k-btn k-btn--tertiary k-btn--sm k-hours__copy" data-act="copy">${s(n.copyAll)}</button></div>`}`,this.paintState(),e&&a.querySelector(e)?.focus()}paintState(){let e=u().businessHours,t=this.root,n=this.week;n.forEach((e,n)=>{let r=S(e),i=t.querySelector(`[data-day="${n}"]`);i.toggleAttribute(`data-invalid`,r.length>0);let a=i.querySelector(`.k-hours__error`);a&&(a.hidden=!r.length),i.querySelectorAll(`.k-hours__range`).forEach((e,t)=>e.toggleAttribute(`data-invalid`,r.includes(t))),i.querySelectorAll(`kashi-time-input`).forEach(e=>{let t=e.querySelector(`input`);t&&r.length&&t.setAttribute(`aria-describedby`,`${this.key}-e${n}`)})});let r=t.querySelector(`.k-hours__foot`);if(r){let t=C(n,v(this.getAttribute(`now`))??/* @__PURE__ */ new Date),i=r.querySelector(`.k-hours__status`);i.toggleAttribute(`data-open`,t),i.lastElementChild.textContent=t?e.openNow:e.closedNow,r.querySelector(`.k-hours__summary`).textContent=w(n,{locale:a()}),r.querySelector(`.k-hours__copy`).hidden=!n.some(e=>e.open&&e.ranges.length)}m(this,this.getAttribute(`name`),this.valid?JSON.stringify(n):``)}};O.observedAttributes=[`value`,`label`,`step`,`max-ranges`,`summary`,`now`,`name`,`digits`,`disabled`],l(`kashi-business-hours`,O,`block`);export{O as KashiBusinessHours};
@@ -0,0 +1 @@
1
+ import{i as e,n as t,r as n,t as r}from"./card-C0nariT-.js";import{a as i,c as a,d as o,f as s,g as c,h as l,i as u,l as d,m as f,n as ee,o as te,p as ne,r as p,s as m,t as h,u as g}from"./legal-id-B_0kbcQT.js";import{M as _,N as v,P as re,_ as ie,c as ae,d as y,i as b,j as x,l as S,o as C,p as w,t as oe,u as T,v as E,y as D}from"./base-BqFAMlwG.js";import{t as O}from"./words-BdADG_9U.js";import{t as k}from"./money-BFEbgLJn.js";function se(e){let t=_(e);return/^\d{16}$/.test(t)&&!/^0+$/.test(t)}function ce(e){return _(e).slice(0,16).replace(/(\d{4})(?=\d)/g,`$1 `)}function A(e){let t=_(e).length;return t===10?`person`:t===11?`company`:t===12?`legacy`:null}function j(e){let t=_(e),n=A(t);return n===`person`?c(t):n===`company`?h(t):n===`legacy`&&!/^0+$/.test(t)}function M(e){return v(e).toUpperCase().replace(/[^0-9A-Z]/g,``)}function le(e){return/^[0-9A-Z]{22}$/.test(M(e))}const ue={1:`water`,2:`electricity`,3:`gas`,4:`landline`,5:`mobile`,6:`municipality`,8:`tax`,9:`fine`};function N(e){let t=0,n=2;for(let r=e.length-1;r>=0;r--)t+=Number(e[r])*n,n=n===7?2:n+1;let r=t%11;return r<2?0:11-r}const P=e=>_(e).replace(/^0+/,``);function F(e){let t=P(e);return t.length<6||t.length>13?null:ue[t[t.length-2]]??null}function I(e){let t=P(e);return!/^\d{6,13}$/.test(t)||!F(t)?!1:N(t.slice(0,-1))===Number(t[t.length-1])}function L(e,t){let n=P(e),r=P(t);return!I(n)||!/^\d{6,13}$/.test(r)||N(r.slice(0,-2))!==Number(r[r.length-2])||N(n+r.slice(0,-1))!==Number(r[r.length-1])?null:{service:F(n),amount:Number(r.slice(0,-5)||`0`)*1e3,year:Number(r[r.length-5]),period:Number(r.slice(-4,-2))}}const R=e=>re(e);function z(e,t){if(t===0)return e.search(/[0-9۰-۹]/)===-1?e.length:e.search(/[0-9۰-۹]/);let n=0;for(let r=0;r<e.length;r++)if(/[0-9۰-۹]/.test(e[r])&&++n===t)return r+1;return e.length}var B=class extends oe{constructor(){super(...arguments),this.raw=``,this.touched=!1,this.valueSet=!1,this.rendered=!1,this.key=D(`kashi-in`),this.logoSlug=null}connectedCallback(){if(!this.rendered&&!this.valueSet&&(this.raw=this.clean(this.getAttribute(`value`)??``)),Object.prototype.hasOwnProperty.call(this,`value`)){let e=this.value;delete this.value,this.raw=this.clean(String(e??``))}this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.setRaw(this.clean(n??``),!1):this.render())}get value(){return this.kind.submit?this.kind.submit(this.raw):this.raw}set value(e){this.valueSet=!0,this.setRaw(this.clean(String(e??``)),!1)}get valid(){return this.isValid()}isValid(){return this.kind.valid(this.raw)}focus(e){this.input?.focus(e)}clean(e){let t=this.kind;return t.alnum?M(e).slice(0,t.maxDigits):(t.normalize??(e=>e))(_(e)).slice(0,t.maxDigits)}get digits(){let e=this.getAttribute(`digits`);return e===`fa`||e===`latin`?e:y()===`en`?`latin`:this.kind.digits}shown(){let e=this.kind.format(this.raw);return this.digits===`fa`?R(e):e}render(){let e=this.kind,t=this.key,n=this.getAttribute(`aria-label`),r=this.hasAttribute(`label`)?this.getAttribute(`label`):n?null:e.label(),i=this.getAttribute(`size`),a=this.hasAttribute(`required`),o=this.hasAttribute(`disabled`),s=this.getAttribute(`placeholder`)??e.placeholder[this.digits],c=`<div class="k-input${i===`sm`||i===`lg`?` k-input--${i}`:``}" data-size="${i??`md`}"${o?` data-state="disabled"`:``}><input id="${t}" class="k-input__control" type="${e.type??`text`}" inputmode="${e.inputMode??`numeric`}" autocomplete="${e.autocomplete??`off`}" dir="ltr" spellcheck="false" placeholder="${S(s)}"${a?` required`:``}${o?` disabled`:``}${this.hasAttribute(`readonly`)?` readonly`:``}${!r&&n?` aria-label="${S(n)}"`:``}></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,T({id:t,label:r,required:a,control:c})),this.input=this.querySelector(`input.k-input__control`),this.input.addEventListener(`input`,()=>this.onInput()),this.input.addEventListener(`blur`,()=>{this.touched=!0,this.paint()}),this.rendered=!0,this.paint()}onInput(){let e=this.input,t=e.value.slice(0,e.selectionStart??e.value.length),n=this.clean(e.value),r=this.kind.alnum,i=Math.min((r?this.clean(t):_(t)).length,n.length);if(this.setRaw(n,!0),e.ownerDocument.activeElement===e){let t=r?i:z(e.value,i);e.setSelectionRange(t,t)}}setRaw(e,t){let n=e!==this.raw;this.raw=e,this.rendered&&(this.paint(),t&&n&&ae(this,`kashi-change`,{value:this.value,valid:this.isValid(),...this.kind.detail?.(this.raw)}))}invalidText(e){return this.raw.length>0&&(e||this.raw.length===this.kind.maxDigits)&&!this.isValid()?this.getAttribute(`invalid-message`)??this.kind.invalidMessage():null}hintText(){return this.getAttribute(`hint`)}paint(){let e=this.input,t=this.shown();e.value!==t&&(e.value=t);let n=e.parentElement;n.querySelector(`:scope > .k-input__addon`)?.remove();let r=b(this,`show-meta`,!0)?this.kind.meta?.(this.raw,this):null,i=`${this.key}-meta`;if(r){let e=document.createElement(`span`);e.className=`k-input__addon`,e.innerHTML=r.bank?`<span class="k-bank" id="${i}">${S(r.text)}</span>`:`<span class="k-input__meta${r.className?` ${r.className}`:``}"${r.service?` data-service="${r.service}"`:``} id="${i}">${S(r.text)}</span>`,n.append(e),r.bank&&b(this,`bank-logo`,!0)&&this.loadLogo(r.bank,e.firstElementChild)}let a=this.getAttribute(`error`)||this.invalidText(this.touched);e.setCustomValidity(this.raw&&!this.isValid()?this.invalidText(!0)??``:``),ie(this.querySelector(`:scope > .k-field`),e,this.key,a,this.hintText(),r?i:null),E(this,this.getAttribute(`name`),this.raw?this.value:``)}loadLogo(e,t){this.logoSlug=e.slug,import(`./dist-D670Gw0K.js`).then(n=>{let r=n.bankLogoDataUri(e.slug);if(!r||this.logoSlug!==e.slug||!t.isConnected)return;let i=document.createElement(`img`);i.className=`k-bank__logo`,i.src=r,i.alt=``,i.width=i.height=24,t.prepend(i)}).catch(()=>{})}};B.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`required`,`disabled`,`readonly`,`digits`,`invalid-message`,`name`,`value`,`size`,`aria-label`,`show-meta`,`bank-logo`];var V=class extends B{constructor(){super(...arguments),this.kind={label:()=>w().persianInput[`national-id`],maxDigits:10,format:e=>e,valid:e=>c(e),invalidMessage:()=>w().invalid.nationalId,placeholder:{fa:`۰۰۰۰۰۰۰۰۰۰`,latin:`0000000000`},digits:`fa`}}},H=class extends B{constructor(){super(...arguments),this.kind={label:()=>w().persianInput[`legal-id`],maxDigits:11,format:e=>e,valid:e=>h(e),invalidMessage:()=>w().invalid.legalId,placeholder:{fa:`۰۰۰۰۰۰۰۰۰۰۰`,latin:`00000000000`},digits:`fa`}}},U=class extends B{constructor(){super(...arguments),this.kind={label:()=>w().persianInput.mobile,maxDigits:11,normalize:o,format:a,valid:e=>g(e),invalidMessage:()=>w().invalid.mobile,placeholder:{fa:`۰۹۱۲ ۳۴۵ ۶۷۸۹`,latin:`0912 345 6789`},digits:`fa`,type:`tel`,inputMode:`tel`,autocomplete:`tel-national`,meta:e=>{let t=d(e);return t?{text:s(t,y())}:null},detail:e=>({operator:d(e)?.name??null})}}},W=class extends B{constructor(){super(...arguments),this.kind={label:()=>w().persianInput.landline,maxDigits:11,normalize:i,format:ee,valid:e=>u(e),invalidMessage:()=>w().invalid.landline,placeholder:{fa:`۰۲۱ ۸۸۷۷ ۶۶۵۵`,latin:`021 8877 6655`},digits:`fa`,type:`tel`,inputMode:`tel`,autocomplete:`tel-national`,meta:e=>{let t=p(e);return t?{text:t}:null},detail:e=>({province:p(e)})}}},G=class extends B{constructor(){super(...arguments),this.kind={label:()=>w().persianInput.card,maxDigits:16,format:t,valid:t=>e(t),invalidMessage:()=>w().invalid.card,placeholder:{fa:`۰۰۰۰ ۰۰۰۰ ۰۰۰۰ ۰۰۰۰`,latin:`0000 0000 0000 0000`},digits:`fa`,autocomplete:`cc-number`,meta:e=>{let t=n(e);return t?{text:r(t,y()),bank:t}:null},detail:e=>({bank:n(e)?.name??null})}}},K=class extends B{constructor(){super(...arguments),this.kind={label:()=>w().persianInput.iban,maxDigits:24,format:e=>ne(e),valid:e=>l(e),invalidMessage:()=>w().invalid.iban,placeholder:{fa:`IR00 0000 0000 0000 0000 0000 00`,latin:`IR00 0000 0000 0000 0000 0000 00`},digits:`latin`,meta:e=>{let t=f(e);return t?{text:r(t,y()),bank:t}:null},submit:e=>e?`IR${e}`:``,detail:e=>({bank:f(e)?.name??null})}}clean(e){return super.clean(e.replace(/^\s*IR/i,``))}},q=class extends B{constructor(){super(...arguments),this.kind={label:()=>w().persianInput.postal,maxDigits:10,format:te,valid:e=>m(e),invalidMessage:()=>w().invalid.postal,placeholder:{fa:`۱۲۳۴۵-۶۷۸۹۰`,latin:`12345-67890`},digits:`fa`,autocomplete:`postal-code`}}},J=class extends B{constructor(){super(...arguments),this.kind={label:()=>w().persianInput.price,maxDigits:15,normalize:e=>e.replace(/^0+(?=\d)/,``),format:e=>e?x(e,{digits:`latin`}).replace(/,/g,this.digits===`fa`?`٬`:`,`):``,valid:()=>this.inRange(),invalidMessage:()=>``,placeholder:{fa:`۰`,latin:`0`},digits:`fa`,meta:(e,t)=>{let n=t.getAttribute(`unit`)??w().money.toman;return n?{text:n}:null},detail:e=>({value:e?Number(e):null})}}get valueAsNumber(){return this.raw?Number(this.raw):null}num(e){let t=this.getAttribute(e);return t===null||t===``||Number.isNaN(Number(t))?void 0:Number(t)}inRange(){if(!this.raw)return!0;let e=Number(this.raw),t=this.num(`min`),n=this.num(`max`);return!(t!==void 0&&e<t||n!==void 0&&e>n)}invalidText(e){if(!e||this.inRange())return null;let t=this.getAttribute(`invalid-message`);if(t)return t;let n=this.num(`min`),r=this.num(`max`),i=e=>this.digits===`fa`?R(x(e)):x(e,{digits:`latin`}),a=w().invalid;return n!==void 0&&r!==void 0?a.priceRange(i(n),i(r)):n===void 0?a.priceMax(i(r)):a.priceMin(i(n))}hintText(){if(this.raw&&b(this,`show-words`,!0)){let e=this.getAttribute(`unit`)??w().money.toman;return`${O(Number(this.raw),{locale:y()})}${e?` ${e}`:``}`}return this.getAttribute(`hint`)}};J.observedAttributes=[...B.observedAttributes,`unit`,`min`,`max`,`show-words`];var Y=class extends B{constructor(){super(...arguments),this.kind={label:()=>w().persianInput.sayad,maxDigits:16,format:ce,valid:e=>se(e),invalidMessage:()=>w().invalid.sayad,placeholder:{fa:`۰۰۰۰ ۰۰۰۰ ۰۰۰۰ ۰۰۰۰`,latin:`0000 0000 0000 0000`},digits:`fa`}}},X=class extends B{constructor(){super(...arguments),this.kind={label:()=>w().persianInput[`economic-code`],maxDigits:12,format:e=>e,valid:e=>j(e),invalidMessage:()=>w().invalid.economicCode,placeholder:{fa:`۰۰۰۰۰۰۰۰۰۰۰`,latin:`00000000000`},digits:`fa`,meta:e=>{let t=A(e);return t&&j(e)?{text:w().taxCode[t]}:null},detail:e=>({type:A(e)})}}},Z=class extends B{constructor(){super(...arguments),this.kind={label:()=>w().persianInput[`tax-id`],maxDigits:22,format:e=>e,valid:e=>le(e),invalidMessage:()=>w().invalid.taxId,placeholder:{fa:`A1B2C3…`,latin:`A1B2C3…`},digits:`latin`,inputMode:`text`,alnum:!0}}},Q=class extends B{constructor(){super(...arguments),this.kind={label:()=>w().persianInput[`bill-id`],maxDigits:13,format:e=>e,normalize:e=>e.replace(/^0+/,``),valid:e=>I(e),invalidMessage:()=>w().invalid.billId,placeholder:{fa:`۰۰۰۰۰۰۰۰۰۰۰۰۰`,latin:`0000000000000`},digits:`fa`,meta:e=>{let t=I(e)?F(e):null;return t?{text:w().bill.service[t],className:`k-bill__service`,service:t}:null},detail:e=>({service:I(e)?F(e):null})}}},$=class extends B{constructor(){super(...arguments),this.kind={label:()=>w().persianInput[`payment-id`],maxDigits:13,format:e=>e,normalize:e=>e.replace(/^0+/,``),valid:e=>L(this.getAttribute(`bill-id`)??``,e)!==null,invalidMessage:()=>w().invalid.paymentId,placeholder:{fa:`۰۰۰۰۰۰۰۰`,latin:`00000000`},digits:`fa`,meta:(e,t)=>{let n=L(t.getAttribute(`bill-id`)??``,e);if(!n)return null;let r=t.getAttribute(`unit`)===`rial`?`rial`:`toman`;return{text:k(n.amount,{from:`rial`,unit:r,locale:y(),digits:this.digits}),className:`k-bill__amount`}},detail:e=>({info:L(this.getAttribute(`bill-id`)??``,e)})}}invalidText(e){return I(this.getAttribute(`bill-id`)??``)?super.invalidText(e):null}hintText(){return this.getAttribute(`hint`)??(I(this.getAttribute(`bill-id`)??``)?null:w().bill.needBill)}};$.observedAttributes=[...B.observedAttributes,`bill-id`,`unit`],C(`kashi-national-id`,V,`block`),C(`kashi-sayad`,Y,`block`),C(`kashi-bill-id`,Q,`block`),C(`kashi-payment-id`,$,`block`),C(`kashi-economic-code`,X,`block`),C(`kashi-tax-id`,Z,`block`),C(`kashi-legal-id`,H,`block`),C(`kashi-mobile`,U,`block`),C(`kashi-landline`,W,`block`),C(`kashi-card-number`,G,`block`),C(`kashi-iban`,K,`block`),C(`kashi-postal-code`,q,`block`),C(`kashi-price`,J,`block`);export{Q as KashiBillId,G as KashiCardNumber,B as KashiDigitsInput,X as KashiEconomicCode,K as KashiIban,W as KashiLandline,H as KashiLegalId,U as KashiMobile,V as KashiNationalId,$ as KashiPaymentId,q as KashiPostalCode,J as KashiPrice,Y as KashiSayad,Z as KashiTaxId};
@@ -0,0 +1,10 @@
1
+ import{C as e,d as t,i as n,j as r,l as i,m as a,o,p as s,s as c,t as l}from"./base-BqFAMlwG.js";import{t as u}from"./words-BdADG_9U.js";import{l as d,p as f}from"./parts-5fVaWtRe.js";const p=e=>typeof e==`string`&&/^\d{4}-\d{2}-\d{2}$/.test(e)?new Date(+e.slice(0,4),e.slice(5,7)-1,+e.slice(8,10)):f(e);var m=class extends l{constructor(){super(...arguments),this.value=null}connectedCallback(){this.render()}attributeChangedCallback(e,t,n){t!==n&&(e===`data`&&(this.value=null),this.isConnected&&this.render())}get data(){return this.value??d(this,`data`,null)}set data(e){this.value=e,this.isConnected&&this.render()}get totals(){let e=this.data,t=e?.items??[],n=t.reduce((e,t)=>e+t.quantity*t.unitPrice,0),r=t.reduce((e,t)=>e+(t.discount??0),0),i=n-r,a=Math.round(i*(e?.vatRate??10)/100);return{subtotal:n,discount:r,taxable:i,vat:a,payable:i+a}}render(){let o=this.data;if(!o){this.innerHTML=``;return}let l=s().invoice,d=c(this),f=e=>r(e,{digits:d}),m=n=>{let r=p(n);return r?e(r,{locale:t(),digits:d}):``},h=this.totals,g=(o.currency??`rial`)===`rial`?l.rial:l.toman,_=o.items.some(e=>e.discount),v=(e,t,n=!1,r=!1)=>t?`<div${r?` class="k-invoice__wide"`:``}><dt>${i(e)}</dt><dd${n?` class="k-invoice__num"`:``}>${i(n?a(this,t):t)}</dd></div>`:``,y=(e,t)=>`<section class="k-invoice__party" aria-label="${i(e)}"><h3 class="k-invoice__party-title">${i(e)}</h3><dl class="k-invoice__dl">${v(l.name,t.name)}${v(l.economicCode,t.economicCode,!0)}${v(l.nationalId,t.nationalId,!0)}${v(l.postal,t.postalCode,!0)}${v(l.phone,t.phone,!0)}${v(l.address,t.address,!1,!0)}</dl></section>`,b=o.variant??`official`,x=`${this.id||`kashi`}-invoice-title`;this.innerHTML=`<article class="k-invoice" data-variant="${b}" aria-labelledby="${x}">
2
+ <header class="k-invoice__head"><h2 class="k-invoice__title" id="${x}">${i(b===`proforma`?l.proforma:l.official)}</h2>
3
+ <dl class="k-invoice__meta"><div><dt>${i(l.number)}</dt><dd>${i(a(this,o.number))}</dd></div><div><dt>${i(l.date)}</dt><dd>${i(m(o.date))}</dd></div>${b===`proforma`&&o.validUntil?`<div><dt>${i(l.validUntil)}</dt><dd>${i(m(o.validUntil))}</dd></div>`:``}${o.taxId?`<div><dt>${i(l.taxId)}</dt><dd dir="ltr" class="k-invoice__mono">${i(o.taxId)}</dd></div>`:``}</dl></header>
4
+ <div class="k-invoice__parties">${y(l.seller,o.seller)}${y(l.buyer,o.buyer)}</div>
5
+ <div class="k-invoice__table-wrap" role="region" tabindex="0" aria-label="${i(l.description)}"><table class="k-invoice__table"><thead><tr><th scope="col" class="k-invoice__num-col">${i(l.row)}</th><th scope="col">${i(l.description)}</th><th scope="col" class="k-invoice__n">${i(l.quantity)}</th><th scope="col" class="k-invoice__n">${i(l.unitPrice)}</th>${_?`<th scope="col" class="k-invoice__n">${i(l.discount)}</th>`:``}<th scope="col" class="k-invoice__n">${i(l.lineTotal)}</th></tr></thead><tbody>${o.items.map((e,t)=>`<tr><td class="k-invoice__num-col">${a(this,t+1)}</td><td>${i(e.description)}${e.code?`<span class="k-invoice__code" dir="ltr">${i(a(this,e.code))}</span>`:``}</td><td class="k-invoice__n">${f(e.quantity)}${e.unit?`<span class="k-invoice__unit"> ${i(e.unit)}</span>`:``}</td><td class="k-invoice__n">${f(e.unitPrice)}</td>${_?`<td class="k-invoice__n">${e.discount?f(e.discount):`—`}</td>`:``}<td class="k-invoice__n">${f(e.quantity*e.unitPrice-(e.discount??0))}</td></tr>`).join(``)}</tbody></table></div>
6
+ <div class="k-invoice__summary"><dl class="k-invoice__totals"><div><dt>${i(l.subtotal)}</dt><dd>${f(h.subtotal)}</dd></div>${h.discount?`<div><dt>${i(l.totalDiscount)}</dt><dd>${f(h.discount)}</dd></div>`:``}<div><dt>${i(l.vat(a(this,o.vatRate??10)))}</dt><dd>${f(h.vat)}</dd></div><div class="k-invoice__payable"><dt>${i(l.payable)}</dt><dd>${f(h.payable)} <span class="k-invoice__cur">${i(g)}</span></dd></div></dl><p class="k-invoice__words">${i(l.inWords(u(h.payable,{locale:t()}),g))}</p></div>
7
+ ${o.notes?`<section class="k-invoice__notes"><h3 class="k-invoice__party-title">${i(l.notes)}</h3><div>${i(o.notes)}</div></section>`:``}
8
+ ${n(this,`signatures`,!0)?`<div class="k-invoice__signs"><div class="k-invoice__sign">${i(l.sellerSign)}</div><div class="k-invoice__sign">${i(l.buyerSign)}</div></div>`:``}
9
+ ${n(this,`print-button`,!0)?`<button type="button" class="k-btn k-btn--secondary k-btn--sm k-invoice__print"><svg viewBox="0 0 20 20" aria-hidden="true" width="16" height="16"><path d="M5.5 7.5V3h9v4.5M5.5 14H4a1.5 1.5 0 0 1-1.5-1.5v-3.5A1.5 1.5 0 0 1 4 7.5h12a1.5 1.5 0 0 1 1.5 1.5v3.5A1.5 1.5 0 0 1 16 14h-1.5M5.5 11.5h9V17h-9z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>${i(l.print)}</button>`:``}
10
+ </article>`,this.querySelector(`.k-invoice__print`)?.addEventListener(`click`,()=>print())}};m.observedAttributes=[`data`,`signatures`,`print-button`],o(`kashi-invoice`,m,`block`);export{m as KashiInvoice};